Implemented the backtracing logic for walking.

This commit is contained in:
Tom Alexander 2020-05-04 23:45:21 -04:00
parent 6bcc66dff5
commit a3bb8e47c1
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 15 additions and 4 deletions

View File

@ -210,16 +210,27 @@ fn walk_path_from_single_level<'a>(
fn new_walk_path<'a>(
breadcrumbs: Vec<&'a dyn ContextElement>,
path: &Vec<&str>,
path: &'a Vec<&str>,
) -> Result<&'a dyn ContextElement, RenderError<'a>> {
for context in breadcrumbs.iter().rev() {
match walk_path_from_single_level(*context, path)? {
// If no walking was done at all, keep looping
WalkResult::NoWalk => {}
WalkResult::PartialWalk => {}
WalkResult::FullyWalked(_) => {}
// If we partially walked then stop trying to find
// anything
WalkResult::PartialWalk => {
return Err(RenderError::NotFound {
path: path,
breadcrumbs: breadcrumbs,
})
}
WalkResult::FullyWalked(new_context) => return Ok(new_context),
}
}
Err(RenderError::Generic("temp".to_owned()))
Err(RenderError::NotFound {
path: path,
breadcrumbs: breadcrumbs,
})
}
// TODO: rename walk_path_from_single_level