aboutsummaryrefslogtreecommitdiffstats
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
commitb70f498d93fc0e5f94a4465883ad654a63efbb39 (patch)
treee7fbb66a21de3e7613d81eb8a592d2709afec81b /rustlings/exercises/11_hashmaps/hashmaps2.rs
parent1b413350c46f8214785e179f60693b78a9bb5f2f (diff)
downloaddemos-b70f498d93fc0e5f94a4465883ad654a63efbb39.tar.gz
demos-b70f498d93fc0e5f94a4465883ad654a63efbb39.zip
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);
}
}