Completed hashmaps

This commit is contained in:
2026-01-09 17:18:22 +01:00
parent 56f173c53b
commit f3b42e5620
7 changed files with 246 additions and 12 deletions

View File

@@ -32,6 +32,17 @@ fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {
// 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!
// basket.entry(Fruit::Pineapple).or_insert(6);
// basket.entry(Fruit::Banana).or_insert(4);
// OR
let quantity = match fruit {
Fruit::Pineapple => 6,
Fruit::Banana => 4,
_ => continue,
};
basket.entry(fruit).or_insert(quantity);
}
}