diff --git a/exercises/collections/hashmap1.rs b/exercises/collections/hashmap1.rs index 64b5a7f..37e964f 100644 --- a/exercises/collections/hashmap1.rs +++ b/exercises/collections/hashmap1.rs @@ -11,17 +11,17 @@ // Execute the command `rustlings hint hashmap1` if you need // hints. -// I AM NOT DONE - use std::collections::HashMap; fn fruit_basket() -> HashMap<String, u32> { - let mut basket = // TODO: declare your hash map here. + let mut basket = HashMap::new();// TODO: declare your hash map here. // Two bananas are already given for you :) basket.insert(String::from("banana"), 2); // TODO: Put more fruits in your basket here. + basket.insert(String::from("apple"), 2); + basket.insert(String::from("orange"), 2); basket } diff --git a/exercises/collections/hashmap2.rs b/exercises/collections/hashmap2.rs index 0abe19a..6044ed5 100644 --- a/exercises/collections/hashmap2.rs +++ b/exercises/collections/hashmap2.rs @@ -12,8 +12,6 @@ // Execute the command `rustlings hint hashmap2` if you need // hints. -// I AM NOT DONE - use std::collections::HashMap; #[derive(Hash, PartialEq, Eq)] @@ -38,6 +36,7 @@ fn fruit_basket(basket: &mut HashMap<Fruit, u32>) { // TODO: Put new fruits if not already present. Note that you // are not allowed to put any type of fruit that's already // present! + basket.entry(fruit).or_insert(1); } }