setup for moving into a multi-step walk function
This commit is contained in:
parent
f62d50df95
commit
43e57f4134
@ -136,8 +136,19 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_the_walk<'a, O: Walkable>(c: &'a dyn Walkable<Output = O>, path: &str) -> &'a O {
|
fn do_the_walk<'a, O: Walkable>(
|
||||||
c.walk(path)
|
context: &'a dyn Walkable<Output = O>,
|
||||||
|
path: &Vec<&str>,
|
||||||
|
) -> &'a O {
|
||||||
|
let mut output = context;
|
||||||
|
|
||||||
|
context.walk(path.first().unwrap())
|
||||||
|
|
||||||
|
// for elem in path.iter() {
|
||||||
|
// output = context.walk(elem);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// output
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -159,10 +170,10 @@ mod tests {
|
|||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(do_the_walk(&context, "cat"), &"kitty");
|
assert_eq!(do_the_walk(&context, &vec!["cat"]), &"kitty");
|
||||||
assert_eq!(do_the_walk(&number_context, "tiger"), &3);
|
assert_eq!(do_the_walk(&number_context, &vec!["tiger"]), &3);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
do_the_walk(&deep_context, "tiger"),
|
do_the_walk(&deep_context, &vec!["tiger"]),
|
||||||
&[("food", "people")].iter().cloned().collect()
|
&[("food", "people")].iter().cloned().collect()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user