summaryrefslogtreecommitdiff
path: root/rustlings/exercises/11_hashmaps/hashmaps2.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rustlings/exercises/11_hashmaps/hashmaps2.rs')
-rw-r--r--rustlings/exercises/11_hashmaps/hashmaps2.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/rustlings/exercises/11_hashmaps/hashmaps2.rs b/rustlings/exercises/11_hashmaps/hashmaps2.rs
index e9f53fe..482db7c 100644
--- a/rustlings/exercises/11_hashmaps/hashmaps2.rs
+++ b/rustlings/exercises/11_hashmaps/hashmaps2.rs
@@ -29,9 +29,11 @@ fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {
];
for fruit in fruit_kinds {
- // TODO: Insert new fruits if they are not already present in the
- // basket. Note that you are not allowed to put any type of fruit that's
- // already present!
+ // This works just fine, but clippy doesn't like how readable and obvious the code is
+ // if !basket.contains_key(&fruit) {
+ // basket.insert(fruit, 10);
+ // }
+ basket.entry(fruit).or_insert(10);
}
}