setup for moving into a multi-step walk function

This commit is contained in:
Tom Alexander 2020-04-11 21:26:36 -04:00
parent f62d50df95
commit 43e57f4134
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -136,8 +136,19 @@ mod tests {
}
}
fn do_the_walk<'a, O: Walkable>(c: &'a dyn Walkable<Output = O>, path: &str) -> &'a O {
c.walk(path)
fn do_the_walk<'a, O: Walkable>(
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]
@ -159,10 +170,10 @@ mod tests {
.iter()
.cloned()
.collect();
assert_eq!(do_the_walk(&context, "cat"), &"kitty");
assert_eq!(do_the_walk(&number_context, "tiger"), &3);
assert_eq!(do_the_walk(&context, &vec!["cat"]), &"kitty");
assert_eq!(do_the_walk(&number_context, &vec!["tiger"]), &3);
assert_eq!(
do_the_walk(&deep_context, "tiger"),
do_the_walk(&deep_context, &vec!["tiger"]),
&[("food", "people")].iter().cloned().collect()
);
}