summaryrefslogtreecommitdiff
path: root/exercises/11_hashmaps
diff options
context:
space:
mode:
authorDaniel Somerfield <daniel@redwinewithfish.org>2024-03-27 20:37:19 -0700
committerDaniel Somerfield <daniel@redwinewithfish.org>2024-03-27 20:37:19 -0700
commit62afbb034f74dc170347d3eff5131e780930d639 (patch)
treec595dda5bca4ee4f034688549a68b253eec91cc7 /exercises/11_hashmaps
parent8bfe2ec71e4800b798d7c0d7b3224ff2530a1c79 (diff)
Move test array to be in test module as vec
Diffstat (limited to 'exercises/11_hashmaps')
-rw-r--r--exercises/11_hashmaps/hashmaps2.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/exercises/11_hashmaps/hashmaps2.rs b/exercises/11_hashmaps/hashmaps2.rs
index ab918cd..a860d7b 100644
--- a/exercises/11_hashmaps/hashmaps2.rs
+++ b/exercises/11_hashmaps/hashmaps2.rs
@@ -27,14 +27,6 @@ enum Fruit {
Pineapple,
}
-const FRUIT_KINDS: [Fruit; 5] = [
- Fruit::Apple,
- Fruit::Banana,
- Fruit::Mango,
- Fruit::Lychee,
- Fruit::Pineapple,
-];
-
fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {
let fruit_kinds = vec![
Fruit::Apple,
@@ -92,9 +84,17 @@ mod tests {
#[test]
fn all_fruit_types_in_basket() {
+ let fruit_kinds = vec![
+ Fruit::Apple,
+ Fruit::Banana,
+ Fruit::Mango,
+ Fruit::Lychee,
+ Fruit::Pineapple,
+ ];
+
let mut basket = get_fruit_basket();
fruit_basket(&mut basket);
- for fruit_kind in FRUIT_KINDS {
+ for fruit_kind in fruit_kinds {
let amount = basket
.get(&fruit_kind)
.expect(format!("Fruit kind {:?} was not found in basket", fruit_kind).as_str());