mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-06 18:59:19 +00:00
Add new fruits to the basket if not already present
This commit is contained in:
parent
551793f249
commit
b42cfb167d
@ -14,8 +14,6 @@
|
|||||||
// Execute `rustlings hint hashmaps2` or use the `hint` watch subcommand for a
|
// Execute `rustlings hint hashmaps2` or use the `hint` watch subcommand for a
|
||||||
// hint.
|
// hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Hash, PartialEq, Eq)]
|
#[derive(Hash, PartialEq, Eq)]
|
||||||
@ -37,6 +35,7 @@ fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for fruit in fruit_kinds {
|
for fruit in fruit_kinds {
|
||||||
|
basket.entry(fruit).or_insert(1);
|
||||||
// TODO: Insert new fruits if they are not already present in the
|
// 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
|
// basket. Note that you are not allowed to put any type of fruit that's
|
||||||
// already present!
|
// already present!
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user