Implemented owned_walk_path.
This commit is contained in:
parent
dade738f55
commit
798d84828e
@ -53,9 +53,21 @@ pub fn walk_path<'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn owned_walk_path<'a>(
|
pub fn owned_walk_path<'a>(
|
||||||
breadcrumbs: &Vec<Box<dyn ContextElement>>,
|
breadcrumbs: &'a Vec<Box<dyn ContextElement>>,
|
||||||
path: &Vec<String>,
|
path: &Vec<String>,
|
||||||
) -> Result<&'a dyn ContextElement, WalkError> {
|
) -> Result<&'a dyn ContextElement, WalkError> {
|
||||||
// TODO: Implement owned_walk_path
|
let path_reference: Vec<&str> = path.iter().map(|p| &p[..]).collect();
|
||||||
|
for context in breadcrumbs.iter().rev() {
|
||||||
|
match walk_path_from_single_level(context.as_ref(), &path_reference) {
|
||||||
|
// If no walking was done at all, keep looping
|
||||||
|
WalkResult::NoWalk => {}
|
||||||
|
// If we partially walked then stop trying to find
|
||||||
|
// anything
|
||||||
|
WalkResult::PartialWalk => {
|
||||||
|
return Err(WalkError::CantWalk);
|
||||||
|
}
|
||||||
|
WalkResult::FullyWalked(new_context) => return Ok(new_context),
|
||||||
|
}
|
||||||
|
}
|
||||||
Err(WalkError::CantWalk)
|
Err(WalkError::CantWalk)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user