Completed hashmaps
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user