summaryrefslogtreecommitdiff
path: root/exercises/hashmaps/hashmaps2.rs
diff options
context:
space:
mode:
authortajo48 <55502906+tajo48@users.noreply.github.com>2023-06-15 00:46:45 +0200
committerGitHub <noreply@github.com>2023-06-15 00:46:45 +0200
commite1704a2f1bd2e1c92e0741d656228fe6ccf36a35 (patch)
tree6bbd1dd1ea127dd652e0fe64093c10a78734fdf5 /exercises/hashmaps/hashmaps2.rs
parent1e02f194fdd1cb1ca99cf1d93d11455db8b1bce6 (diff)
parent0282da6881c0708b5aaf6a01e731b88b61201f71 (diff)
Merge branch 'main' into main
Diffstat (limited to 'exercises/hashmaps/hashmaps2.rs')
-rw-r--r--exercises/hashmaps/hashmaps2.rs36
1 files changed, 23 insertions, 13 deletions
diff --git a/exercises/hashmaps/hashmaps2.rs b/exercises/hashmaps/hashmaps2.rs
index a4f069a..a592569 100644
--- a/exercises/hashmaps/hashmaps2.rs
+++ b/exercises/hashmaps/hashmaps2.rs
@@ -1,17 +1,18 @@
// hashmaps2.rs
-// We're collecting different fruits to bake a delicious fruit cake.
-// For this, we have a basket, which we'll represent in the form of a hash
-// map. The key represents the name of each fruit we collect and the value
-// represents how many of that particular fruit we have collected.
-// Three types of fruits - Apple (4), Mango (2) and Lychee (5) are already
-// in the basket hash map.
-// You must add fruit to the basket so that there is at least
-// one of each kind and more than 11 in total - we have a lot of mouths to feed.
-// You are not allowed to insert any more of these fruits!
+//
+// We're collecting different fruits to bake a delicious fruit cake. For this,
+// we have a basket, which we'll represent in the form of a hash map. The key
+// represents the name of each fruit we collect and the value represents how
+// many of that particular fruit we have collected. Three types of fruits -
+// Apple (4), Mango (2) and Lychee (5) are already in the basket hash map. You
+// must add fruit to the basket so that there is at least one of each kind and
+// more than 11 in total - we have a lot of mouths to feed. You are not allowed
+// to insert any more of these fruits!
//
// Make me pass the tests!
//
-// Execute `rustlings hint hashmaps2` or use the `hint` watch subcommand for a hint.
+// Execute `rustlings hint hashmaps2` or use the `hint` watch subcommand for a
+// hint.
// I AM NOT DONE
@@ -36,9 +37,9 @@ 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!
+ // 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!
}
}
@@ -80,4 +81,13 @@ mod tests {
let count = basket.values().sum::<u32>();
assert!(count > 11);
}
+
+ #[test]
+ fn all_fruit_types_in_basket() {
+ let mut basket = get_fruit_basket();
+ fruit_basket(&mut basket);
+ for amount in basket.values() {
+ assert_ne!(amount, &0);
+ }
+ }
}