diff --git a/src/renderer/renderer.rs b/src/renderer/renderer.rs index 78192ec..94c6e3b 100644 --- a/src/renderer/renderer.rs +++ b/src/renderer/renderer.rs @@ -95,27 +95,25 @@ impl<'a> DustRenderer<'a> { } } -fn walk_path<'a, C>(context: &'a C, path: &Vec<&str>) -> &'a C -where - C: Walkable, -{ - let mut output: &C = context; +// fn walk_path<'a, C>(context: &'a C, path: &Vec<&str>) -> &'a C +// where +// C: Walkable, +// { +// let mut output: &C = context; - for elem in path.iter() { - output = context.walk(elem); - } +// for elem in path.iter() { +// output = context.walk(elem); +// } - output -} +// output +// } #[cfg(test)] mod tests { use super::*; impl<'a, I: Walkable> Walkable for HashMap<&str, I> { - type Output = I; - - fn walk(&self, segment: &str) -> &I { + fn walk(&self, segment: &str) -> &dyn Walkable { self.get(segment).unwrap() } @@ -125,9 +123,7 @@ mod tests { } impl<'a> Walkable for &str { - type Output = u32; - - fn walk(&self, segment: &str) -> &u32 { + fn walk(&self, segment: &str) -> &dyn Walkable { panic!("Tried to walk down a str"); } @@ -137,9 +133,7 @@ mod tests { } impl<'a> Walkable for u32 { - type Output = u32; - - fn walk(&self, segment: &str) -> &u32 { + fn walk(&self, segment: &str) -> &dyn Walkable { panic!("Tried to walk down a str"); } @@ -148,7 +142,7 @@ mod tests { } } - fn do_the_walk<'a>(context: &'a impl Walkable, path: &Vec<&str>) -> &'a impl Walkable { + fn do_the_walk<'a>(context: &'a impl Walkable, path: &Vec<&str>) -> &'a dyn Walkable { let mut output = context; context.walk(path.first().unwrap()) diff --git a/src/renderer/walkable.rs b/src/renderer/walkable.rs index f93eef1..e8bf09f 100644 --- a/src/renderer/walkable.rs +++ b/src/renderer/walkable.rs @@ -1,9 +1,9 @@ use super::renderable::Renderable; pub trait Walkable { - type Output: Walkable; + // type Output: Walkable; - fn walk(&self, segment: &str) -> &Self::Output; + fn walk(&self, segment: &str) -> &dyn Walkable; fn val(&self) -> String; }