From 54e6613f14ceac07298510a320ce23789c671892 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 11 Apr 2020 21:12:42 -0400 Subject: [PATCH] do_the_walk may be generic now? --- src/renderer/renderer.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderer/renderer.rs b/src/renderer/renderer.rs index 6bd7778..0426e8f 100644 --- a/src/renderer/renderer.rs +++ b/src/renderer/renderer.rs @@ -136,7 +136,7 @@ mod tests { } } - fn do_the_walk<'a>(c: &'a (dyn Walkable), path: &str) -> &'a str { + fn do_the_walk<'a, O: Walkable>(c: &'a dyn Walkable, 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"); } }