From a3bb8e47c15ae08eb1a083d0184c2b79d3e3c8f4 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 4 May 2020 23:45:21 -0400 Subject: [PATCH] Implemented the backtracing logic for walking. --- src/renderer/renderer.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/renderer/renderer.rs b/src/renderer/renderer.rs index c0a2a64..f430d28 100644 --- a/src/renderer/renderer.rs +++ b/src/renderer/renderer.rs @@ -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