Add support for dot paths to owned_walk_path.
This commit is contained in:
parent
1ad9753845
commit
a58b605e59
@ -74,7 +74,30 @@ pub fn owned_walk_path<'a>(
|
||||
breadcrumbs: &'a Vec<Box<dyn ContextElement>>,
|
||||
path: &Vec<String>,
|
||||
) -> Result<&'a dyn ContextElement, WalkError> {
|
||||
if path.is_empty() {
|
||||
return Ok(breadcrumbs
|
||||
.last()
|
||||
.expect("Breadcrumbs should never be empty")
|
||||
.as_ref());
|
||||
}
|
||||
|
||||
let path_reference: Vec<&str> = path.iter().map(|p| &p[..]).collect();
|
||||
if path.first().expect("Already proved path is not empty") == "." {
|
||||
return match walk_path_from_single_level(
|
||||
breadcrumbs
|
||||
.last()
|
||||
.expect("Breadcrumbs should never be empty")
|
||||
.as_ref(),
|
||||
&path_reference[1..],
|
||||
) {
|
||||
// If no walking was done at all or we partially walked
|
||||
// then stop trying to find anything because '.' restricts
|
||||
// us to the current scope
|
||||
WalkResult::NoWalk | WalkResult::PartialWalk => Err(WalkError::CantWalk),
|
||||
WalkResult::FullyWalked(new_context) => Ok(new_context),
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user