From fcb2f3fc4d81c17707b6adf933c3009a8f4ae7f3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 9 May 2020 14:00:19 -0400 Subject: [PATCH] Going extreme: removing all fields and unifying all walk errors. --- src/renderer/context_element.rs | 3 ++- src/renderer/errors.rs | 11 ++--------- src/renderer/renderer.rs | 3 ++- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/renderer/context_element.rs b/src/renderer/context_element.rs index 14f1aae..bc12234 100644 --- a/src/renderer/context_element.rs +++ b/src/renderer/context_element.rs @@ -1,11 +1,12 @@ use crate::parser::Filter; use crate::renderer::errors::RenderError; +use crate::renderer::errors::WalkError; use std::fmt::Debug; pub trait ContextElement: Debug + Walkable + Renderable + Loopable {} pub trait Walkable { - fn walk(&self, segment: &str) -> Result<&dyn ContextElement, RenderError>; + fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError>; } pub trait Renderable { diff --git a/src/renderer/errors.rs b/src/renderer/errors.rs index 6eb65ad..d9fa346 100644 --- a/src/renderer/errors.rs +++ b/src/renderer/errors.rs @@ -15,15 +15,8 @@ pub enum RenderError<'a> { }, } -pub enum WalkError<'a> { - CantWalk { - segment: String, - elem: &'a dyn ContextElement, - }, - NotFound { - path: &'a Vec<&'a str>, - breadcrumbs: Vec<&'a dyn ContextElement>, - }, +pub enum WalkError { + CantWalk, } #[derive(Clone)] diff --git a/src/renderer/renderer.rs b/src/renderer/renderer.rs index 7d2e9da..dbfd823 100644 --- a/src/renderer/renderer.rs +++ b/src/renderer/renderer.rs @@ -7,6 +7,7 @@ use crate::parser::TemplateElement; use crate::renderer::context_element::ContextElement; use crate::renderer::errors::CompileError; use crate::renderer::errors::RenderError; +use crate::renderer::errors::WalkError; use crate::renderer::parameters_context::ParametersContext; use std::collections::HashMap; @@ -226,7 +227,7 @@ fn walk_path_from_single_level<'a>( let mut output = context; for elem in path.iter() { let new_val = output.walk(elem); - if let Err(RenderError::CantWalk { .. }) = new_val { + if let Err(WalkError::CantWalk { .. }) = new_val { return Ok(walk_failure); } walk_failure = WalkResult::PartialWalk;