summaryrefslogtreecommitdiff
path: root/rustlings/exercises/11_hashmaps/hashmaps2.rs
diff options
context:
space:
mode:
authorHunter Kvalevog <hunter@kvog.sh>2026-09-27 11:08:08 -0500
committerHunter Kvalevog <hunter@kvog.sh>2026-09-27 11:08:08 -0500
commit0fcfd332dd5057a590371c28ed3e6b267f788b76 (patch)
treee7fbb66a21de3e7613d81eb8a592d2709afec81b /rustlings/exercises/11_hashmaps/hashmaps2.rs
parent4abf853ebed9608583a39b13ab3cd3f14ecd1f4b (diff)
rustlings: complete 11
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);
}
}