Add new fruits to the basket if not already present

This commit is contained in:
Rock070 2023-12-30 17:15:50 +08:00
parent 551793f249
commit b42cfb167d

View File

@ -14,8 +14,6 @@
// Execute `rustlings hint hashmaps2` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
use std::collections::HashMap;
#[derive(Hash, PartialEq, Eq)]
@ -37,6 +35,7 @@ fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {
];
for fruit in fruit_kinds {
basket.entry(fruit).or_insert(1);
// 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!