I think its working
This commit is contained in:
parent
5efa650b67
commit
47bb055b67
@ -139,30 +139,18 @@ mod tests {
|
|||||||
fn walk(&self, segment: &str) -> &dyn ContextElement {
|
fn walk(&self, segment: &str) -> &dyn ContextElement {
|
||||||
self.get(segment).unwrap()
|
self.get(segment).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn val(&self) -> String {
|
|
||||||
"val".to_owned()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Walkable for &str {
|
impl Walkable for &str {
|
||||||
fn walk(&self, segment: &str) -> &dyn ContextElement {
|
fn walk(&self, segment: &str) -> &dyn ContextElement {
|
||||||
panic!("Tried to walk down a str");
|
panic!("Tried to walk down a str");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn val(&self) -> String {
|
|
||||||
"val".to_owned()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Walkable for u32 {
|
impl Walkable for u32 {
|
||||||
fn walk(&self, segment: &str) -> &dyn ContextElement {
|
fn walk(&self, segment: &str) -> &dyn ContextElement {
|
||||||
panic!("Tried to walk down a str");
|
panic!("Tried to walk down a str");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn val(&self) -> String {
|
|
||||||
"val".to_owned()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_the_walk<'a>(
|
fn do_the_walk<'a>(
|
||||||
@ -172,7 +160,7 @@ mod tests {
|
|||||||
let mut output = context;
|
let mut output = context;
|
||||||
|
|
||||||
for elem in path.iter() {
|
for elem in path.iter() {
|
||||||
output = context.walk(elem);
|
output = output.walk(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
output
|
output
|
||||||
@ -199,9 +187,9 @@ mod tests {
|
|||||||
.collect();
|
.collect();
|
||||||
assert_eq!(do_the_walk(&context, &vec!["cat"]).render(), "kitty");
|
assert_eq!(do_the_walk(&context, &vec!["cat"]).render(), "kitty");
|
||||||
assert_eq!(do_the_walk(&number_context, &vec!["tiger"]).render(), "3");
|
assert_eq!(do_the_walk(&number_context, &vec!["tiger"]).render(), "3");
|
||||||
// assert_eq!(
|
assert_eq!(
|
||||||
// do_the_walk(&deep_context, &vec!["tiger", "food"]).render(),
|
do_the_walk(&deep_context, &vec!["tiger", "food"]).render(),
|
||||||
// "people"
|
"people"
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
use super::renderable::Renderable;
|
use super::renderable::Renderable;
|
||||||
|
use std::fmt::Debug;
|
||||||
|
|
||||||
pub trait ContextElement: Walkable + Renderable {}
|
pub trait ContextElement: Walkable + Renderable + Debug {}
|
||||||
|
|
||||||
pub trait Walkable {
|
pub trait Walkable {
|
||||||
fn walk(&self, segment: &str) -> &dyn ContextElement;
|
fn walk(&self, segment: &str) -> &dyn ContextElement;
|
||||||
|
|
||||||
fn val(&self) -> String;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user