The structure is all there, just need to implement owned_walk_path and clone on NewParametersContext.

This commit is contained in:
Tom Alexander 2020-05-10 21:34:18 -04:00
parent 4e274b9ea5
commit dade738f55
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 15 additions and 3 deletions

View File

@ -3,6 +3,7 @@ use crate::parser::{Filter, RValue};
use crate::renderer::context_element::CloneIntoBoxedContextElement; use crate::renderer::context_element::CloneIntoBoxedContextElement;
use crate::renderer::context_element::CompareContextElement; use crate::renderer::context_element::CompareContextElement;
use crate::renderer::context_element::ContextElement; use crate::renderer::context_element::ContextElement;
use crate::renderer::walking::owned_walk_path;
use crate::renderer::walking::walk_path; use crate::renderer::walking::walk_path;
use crate::renderer::Loopable; use crate::renderer::Loopable;
use crate::renderer::RenderError; use crate::renderer::RenderError;
@ -94,7 +95,7 @@ impl Walkable for NewParametersContext {
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError> { fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError> {
let rval = self.params.get(segment).ok_or(WalkError::CantWalk)?; let rval = self.params.get(segment).ok_or(WalkError::CantWalk)?;
match rval { match rval {
OwnedRValue::RVPath(path) => walk_path(self.breadcrumbs, &path.keys), OwnedRValue::RVPath(path) => owned_walk_path(&self.breadcrumbs, &path.keys),
OwnedRValue::RVString(text) => Ok(text), OwnedRValue::RVString(text) => Ok(text),
} }
} }
@ -102,8 +103,11 @@ impl Walkable for NewParametersContext {
impl Clone for NewParametersContext { impl Clone for NewParametersContext {
fn clone(&self) -> Self { fn clone(&self) -> Self {
// TODO: What is this doing, really? // TODO: Implement clone
*self NewParametersContext {
params: HashMap::new(),
breadcrumbs: Vec::new(),
}
} }
} }

View File

@ -51,3 +51,11 @@ pub fn walk_path<'a>(
} }
Err(WalkError::CantWalk) Err(WalkError::CantWalk)
} }
pub fn owned_walk_path<'a>(
breadcrumbs: &Vec<Box<dyn ContextElement>>,
path: &Vec<String>,
) -> Result<&'a dyn ContextElement, WalkError> {
// TODO: Implement owned_walk_path
Err(WalkError::CantWalk)
}