Put IntoContextElement everywhere. It compiles again.
This commit is contained in:
@@ -26,6 +26,7 @@ use std::{cmp::Ordering, collections::HashMap};
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum OwnedRValue {
|
||||
RVPath(OwnedPath),
|
||||
RVTemplate(Vec<PartialNameElement>),
|
||||
RVLiteral(OwnedLiteral),
|
||||
}
|
||||
|
||||
@@ -38,9 +39,7 @@ impl From<&RValue<'_>> for OwnedRValue {
|
||||
fn from(original: &RValue<'_>) -> Self {
|
||||
match original {
|
||||
RValue::RVLiteral(literal) => OwnedRValue::RVLiteral(literal.clone()),
|
||||
RValue::RVTemplate(template) => {
|
||||
OwnedRValue::RVLiteral(OwnedLiteral::LString("TODO".to_owned()))
|
||||
}
|
||||
RValue::RVTemplate(template) => OwnedRValue::RVTemplate(template.clone()),
|
||||
RValue::RVPath(path) => OwnedRValue::RVPath(OwnedPath {
|
||||
keys: path.keys.iter().map(|k| k.to_string()).collect(),
|
||||
}),
|
||||
@@ -51,16 +50,19 @@ impl From<&RValue<'_>> for OwnedRValue {
|
||||
#[derive(Debug)]
|
||||
pub struct ParametersContext {
|
||||
params: HashMap<String, OwnedRValue>,
|
||||
breadcrumbs: Vec<Box<dyn ContextElement>>,
|
||||
breadcrumbs: Vec<Box<dyn IntoContextElement>>,
|
||||
}
|
||||
|
||||
impl ParametersContext {
|
||||
pub fn new(breadcrumbs: &Vec<&dyn ContextElement>, params: &Vec<KVPair>) -> ParametersContext {
|
||||
pub fn new(
|
||||
breadcrumbs: &Vec<&dyn IntoContextElement>,
|
||||
params: &Vec<KVPair>,
|
||||
) -> ParametersContext {
|
||||
let owned_params: HashMap<String, OwnedRValue> = params
|
||||
.iter()
|
||||
.map(|kvpair| (kvpair.key.to_string(), OwnedRValue::from(&kvpair.value)))
|
||||
.collect();
|
||||
let owned_breadcrumbs: Vec<Box<dyn ContextElement>> =
|
||||
let owned_breadcrumbs: Vec<Box<dyn IntoContextElement>> =
|
||||
breadcrumbs.iter().map(|ce| ce.clone_to_box()).collect();
|
||||
|
||||
ParametersContext {
|
||||
@@ -100,10 +102,11 @@ impl Loopable for ParametersContext {
|
||||
}
|
||||
|
||||
impl Walkable for ParametersContext {
|
||||
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError> {
|
||||
fn walk(&self, segment: &str) -> Result<&dyn IntoContextElement, WalkError> {
|
||||
let rval = self.params.get(segment).ok_or(WalkError::CantWalk)?;
|
||||
match rval {
|
||||
OwnedRValue::RVPath(path) => walk_path(&self.breadcrumbs, &path.keys),
|
||||
OwnedRValue::RVTemplate(template) => Ok(template),
|
||||
OwnedRValue::RVLiteral(literal) => Ok(literal),
|
||||
}
|
||||
}
|
||||
@@ -120,7 +123,7 @@ impl Clone for ParametersContext {
|
||||
.iter()
|
||||
.map(|(k, v)| (k.clone(), v.clone()))
|
||||
.collect();
|
||||
let new_breadcrumbs: Vec<Box<dyn ContextElement>> = self
|
||||
let new_breadcrumbs: Vec<Box<dyn IntoContextElement>> = self
|
||||
.breadcrumbs
|
||||
.iter()
|
||||
.map(|bread| bread.clone_to_box())
|
||||
@@ -171,7 +174,7 @@ impl Loopable for OwnedLiteral {
|
||||
}
|
||||
|
||||
impl Walkable for OwnedLiteral {
|
||||
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError> {
|
||||
fn walk(&self, segment: &str) -> Result<&dyn IntoContextElement, WalkError> {
|
||||
Err(WalkError::CantWalk)
|
||||
}
|
||||
}
|
||||
@@ -238,7 +241,17 @@ impl CompareContextElement for OwnedLiteral {
|
||||
}
|
||||
|
||||
impl IntoContextElement for Vec<PartialNameElement> {
|
||||
fn into_context_element(&self) -> &dyn ContextElement {
|
||||
fn into_context_element(
|
||||
&self,
|
||||
breadcrumbs: &Vec<&dyn IntoContextElement>,
|
||||
) -> &dyn ContextElement {
|
||||
// TODO
|
||||
&OwnedLiteral::LPositiveInteger(1)
|
||||
}
|
||||
}
|
||||
|
||||
impl Walkable for Vec<PartialNameElement> {
|
||||
fn walk(&self, segment: &str) -> Result<&dyn IntoContextElement, WalkError> {
|
||||
Err(WalkError::CantWalk)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user