Generic implementation of CloneIntoBoxedContextElement.
This commit is contained in:
parent
ba79369b5a
commit
256051220d
@ -1,7 +1,7 @@
|
||||
extern crate nom;
|
||||
|
||||
use crate::renderer::CloneIntoBoxedContextElement;
|
||||
use crate::renderer::CompareContextElement;
|
||||
use crate::renderer::IntoBoxedContextElement;
|
||||
use parser::Filter;
|
||||
use renderer::compile_template;
|
||||
use renderer::CompiledTemplate;
|
||||
@ -141,12 +141,6 @@ impl Loopable for serde_json::Value {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoBoxedContextElement for serde_json::Value {
|
||||
fn clone_to_box(&self) -> Box<dyn ContextElement> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl CompareContextElement for serde_json::Value {
|
||||
fn to_any(&self) -> &dyn Any {
|
||||
self
|
||||
|
@ -5,7 +5,7 @@ use std::any::Any;
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub trait ContextElement:
|
||||
Debug + Walkable + Renderable + Loopable + IntoBoxedContextElement + CompareContextElement
|
||||
Debug + Walkable + Renderable + Loopable + CloneIntoBoxedContextElement + CompareContextElement
|
||||
{
|
||||
}
|
||||
|
||||
@ -36,10 +36,16 @@ pub trait CompareContextElement {
|
||||
fn equals(&self, other: &dyn ContextElement) -> bool;
|
||||
}
|
||||
|
||||
pub trait IntoBoxedContextElement {
|
||||
pub trait CloneIntoBoxedContextElement {
|
||||
fn clone_to_box(&self) -> Box<dyn ContextElement>;
|
||||
}
|
||||
|
||||
impl<C: 'static + ContextElement + Clone> CloneIntoBoxedContextElement for C {
|
||||
fn clone_to_box(&self) -> Box<dyn ContextElement> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> PartialEq<&'b dyn ContextElement> for &'a dyn ContextElement {
|
||||
fn eq(&self, other: &&'b dyn ContextElement) -> bool {
|
||||
self.equals(*other)
|
||||
|
@ -7,9 +7,9 @@ mod parameters_context;
|
||||
mod renderer;
|
||||
mod walking;
|
||||
|
||||
pub use context_element::CloneIntoBoxedContextElement;
|
||||
pub use context_element::CompareContextElement;
|
||||
pub use context_element::ContextElement;
|
||||
pub use context_element::IntoBoxedContextElement;
|
||||
pub use context_element::Loopable;
|
||||
pub use context_element::Renderable;
|
||||
pub use context_element::Walkable;
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::parser::KVPair;
|
||||
use crate::parser::{Filter, RValue};
|
||||
use crate::renderer::context_element::CloneIntoBoxedContextElement;
|
||||
use crate::renderer::context_element::CompareContextElement;
|
||||
use crate::renderer::context_element::ContextElement;
|
||||
use crate::renderer::context_element::IntoBoxedContextElement;
|
||||
use crate::renderer::walking::walk_path;
|
||||
use crate::renderer::Loopable;
|
||||
use crate::renderer::RenderError;
|
||||
@ -143,12 +143,6 @@ impl Walkable for String {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoBoxedContextElement for String {
|
||||
fn clone_to_box(&self) -> Box<dyn ContextElement> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl CompareContextElement for String {
|
||||
fn to_any(&self) -> &dyn Any {
|
||||
self
|
||||
|
@ -245,23 +245,9 @@ impl<'a> DustRenderer<'a> {
|
||||
RValue::RVPath(path) => walk_path(breadcrumbs, &path.keys),
|
||||
},
|
||||
};
|
||||
// if left_side.unwrap().equals(right_side.unwrap()) {
|
||||
// panic!("testing");
|
||||
// }
|
||||
// if left_side.unwrap() == right_side.unwrap() {
|
||||
// panic!("testing");
|
||||
// }
|
||||
if left_side == right_side {
|
||||
panic!("testing");
|
||||
}
|
||||
// let x = WalkError::CantWalk;
|
||||
// let y = WalkError::CantWalk;
|
||||
// if x == y {
|
||||
// panic!("placeholder");
|
||||
// }
|
||||
// if left_side.unwrap() == right_side.unwrap() {
|
||||
// panic!("placeholder");
|
||||
// }
|
||||
}
|
||||
_ => (), // TODO: Implement the rest
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user