Remove CantRender, it was unused.

This commit is contained in:
Tom Alexander 2020-05-09 13:46:12 -04:00
parent efd103b84a
commit 2108f5cace
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 3 additions and 8 deletions

View File

@ -18,10 +18,6 @@ pub enum RenderError<'a> {
path: &'a Vec<&'a str>,
breadcrumbs: Vec<&'a dyn ContextElement>,
},
/// Attempting to render and unrenderable type (for example, an object without any filters)
CantRender {
elem: &'a dyn ContextElement,
},
}
#[derive(Clone)]
@ -39,7 +35,6 @@ impl fmt::Display for RenderError<'_> {
RenderError::WontWalk { segment, elem } => {
write!(f, "Failed to walk to {} from {:?}", segment, elem)
}
RenderError::CantRender { elem } => write!(f, "Cant render {:?}", elem),
RenderError::NotFound { path, breadcrumbs } => {
write!(f, "Could not find {:?} in {:?}", path, breadcrumbs)
}
@ -57,7 +52,6 @@ impl fmt::Debug for RenderError<'_> {
RenderError::WontWalk { segment, elem } => {
write!(f, "Failed to walk to {} from {:?}", segment, elem)
}
RenderError::CantRender { elem } => write!(f, "Cant render {:?}", elem),
RenderError::NotFound { path, breadcrumbs } => {
write!(f, "Could not find {:?} in {:?}", path, breadcrumbs)
}

View File

@ -181,7 +181,8 @@ impl<'a> DustRenderer<'a> {
let injected_context = ParametersContext::new(breadcrumbs, &partial.params);
let mut new_breadcrumbs = breadcrumbs.clone();
new_breadcrumbs.insert(new_breadcrumbs.len() - 1, &injected_context);
let rendered_content = self.render(&partial.name, &new_breadcrumbs)?;
// TODO: Change unwrap to ?
let rendered_content = self.render(&partial.name, &new_breadcrumbs).unwrap();
return Ok(rendered_content);
}
}
@ -291,7 +292,7 @@ mod tests {
impl<I: ContextElement> Renderable for HashMap<&str, I> {
fn render(&self, _filters: &Vec<Filter>) -> Result<String, RenderError> {
// TODO: handle the filters
Err(RenderError::CantRender { elem: self })
Ok("[object Object]".to_owned())
}
}