Implement walking for a single segment,
This commit is contained in:
parent
c3fe7b47af
commit
033fc9de6b
@ -178,18 +178,41 @@ impl<'a> DustRenderer<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn new_walk_path<'a>(
|
||||
enum WalkResult<'a> {
|
||||
NoWalk,
|
||||
PartialWalk,
|
||||
FullyWalked(&'a dyn ContextElement),
|
||||
}
|
||||
|
||||
fn walk_path_from_single_level<'a>(
|
||||
context: &'a dyn ContextElement,
|
||||
path: &Vec<&str>,
|
||||
breadcrumbs: Vec<&'a dyn ContextElement>,
|
||||
) -> Result<&'a dyn ContextElement, RenderError<'a>> {
|
||||
let mut output = context;
|
||||
|
||||
for elem in path.iter() {
|
||||
output = output.walk(elem)?;
|
||||
) -> Result<WalkResult<'a>, RenderError<'a>> {
|
||||
if path.is_empty() {
|
||||
return Ok(WalkResult::FullyWalked(context));
|
||||
}
|
||||
|
||||
Ok(output)
|
||||
let mut walk_failure = WalkResult::NoWalk;
|
||||
let mut output = context;
|
||||
for elem in path.iter() {
|
||||
let new_val = output.walk(elem);
|
||||
if let Err(RenderError::WontWalk { .. }) = new_val {
|
||||
return Ok(walk_failure);
|
||||
} else if let Err(RenderError::CantWalk { .. }) = new_val {
|
||||
return Ok(walk_failure);
|
||||
}
|
||||
walk_failure = WalkResult::PartialWalk;
|
||||
output = new_val?;
|
||||
}
|
||||
|
||||
Ok(WalkResult::FullyWalked(context))
|
||||
}
|
||||
|
||||
fn new_walk_path<'a>(
|
||||
breadcrumbs: Vec<&'a dyn ContextElement>,
|
||||
path: &Vec<&str>,
|
||||
) -> Result<&'a dyn ContextElement, RenderError<'a>> {
|
||||
Err(RenderError::Generic("temp".to_owned()))
|
||||
}
|
||||
|
||||
// TODO: rename walk_path_from_single_level
|
||||
|
Loading…
Reference in New Issue
Block a user