diff --git a/exercises/iterators/iterators5.rs b/exercises/iterators/iterators5.rs index 0593d12..bf4e6c6 100644 --- a/exercises/iterators/iterators5.rs +++ b/exercises/iterators/iterators5.rs @@ -10,8 +10,6 @@ // // Make the code compile and the tests pass. -// I AM NOT DONE - use std::collections::HashMap; #[derive(Clone, Copy, PartialEq, Eq)] @@ -34,7 +32,7 @@ fn count_for(map: &HashMap, value: Progress) -> usize { fn count_iterator(map: &HashMap, value: Progress) -> usize { // map is a hashmap with String keys and Progress values. // map = { "variables1": Complete, "from_str": None, ... } - todo!(); + map.values().filter(|v| v == &&value).count() } fn count_collection_for(collection: &[HashMap], value: Progress) -> usize { @@ -53,7 +51,7 @@ fn count_collection_iterator(collection: &[HashMap], value: Pr // collection is a slice of hashmaps. // collection = [{ "variables1": Complete, "from_str": None, ... }, // { "variables2": Complete, ... }, ... ] - todo!(); + collection.iter().map(|hm| count_iterator(&hm, value)).fold(0, |a, b| a + b) } #[cfg(test)]