diff options
| author | Hunter Kvalevog <hunter@kvog.sh> | 2026-09-27 11:08:08 -0500 |
|---|---|---|
| committer | Hunter Kvalevog <hunter@kvog.sh> | 2026-09-27 11:08:08 -0500 |
| commit | 0fcfd332dd5057a590371c28ed3e6b267f788b76 (patch) | |
| tree | e7fbb66a21de3e7613d81eb8a592d2709afec81b /rustlings/exercises/11_hashmaps/hashmaps2.rs | |
| parent | 4abf853ebed9608583a39b13ab3cd3f14ecd1f4b (diff) | |
rustlings: complete 11
Diffstat (limited to 'rustlings/exercises/11_hashmaps/hashmaps2.rs')
| -rw-r--r-- | rustlings/exercises/11_hashmaps/hashmaps2.rs | 8 |
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); } } |