do_the_walk may be generic now?

This commit is contained in:
Tom Alexander 2020-04-11 21:12:42 -04:00
parent c647301662
commit 54e6613f14
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 6 additions and 2 deletions

View File

@ -136,7 +136,7 @@ mod tests {
}
}
fn do_the_walk<'a>(c: &'a (dyn Walkable<Output = &str>), path: &str) -> &'a str {
fn do_the_walk<'a, O: Walkable>(c: &'a dyn Walkable<Output = O>, path: &str) -> &'a O {
c.walk(path)
}
@ -147,6 +147,10 @@ mod tests {
.iter()
.cloned()
.collect();
assert_eq!(do_the_walk(&context, "cat"), "kitty");
let number_context: HashMap<&str, u32> = [("cat", 1), ("dog", 2), ("tiger", 3)]
.iter()
.cloned()
.collect();
assert_eq!(do_the_walk(&context, "cat"), &"kitty");
}
}