@@ -356,6 +356,52 @@ its internal structure (the `fruits` and `veggies` modules and
356
356
associated constants). It's almost there except for one keyword missing for
357
357
each constant."""
358
358
359
+ # COLLECTIONS
360
+
361
+ [[exercises ]]
362
+ name = " collections1"
363
+ path = " exercises/collections/vec1.rs"
364
+ mode = " test"
365
+ hint = """
366
+ In Rust, there are two ways to define a Vector.
367
+ 1. One way is to use the `Vec::new()` function to create a new vector
368
+ and fill it with the `push()` method.
369
+ 2. The second way, which is simpler is to use the `vec![]` macro and
370
+ define your elements inside the square brackets.
371
+ Check this chapter: https://doc.rust-lang.org/stable/book/ch08-01-vectors.html
372
+ of the Rust book to learn more.
373
+ """
374
+
375
+ [[exercises ]]
376
+ name = " collections2"
377
+ path = " exercises/collections/vec2.rs"
378
+ mode = " test"
379
+ hint = """
380
+ Hint 1: `i` is each element from the Vec as they are being iterated.
381
+ Can you try multiplying this?
382
+ Hint 2: Check the suggestion from the compiler error ;)
383
+ """
384
+
385
+ [[exercises ]]
386
+ name = " collections3"
387
+ path = " exercises/collections/hashmap1.rs"
388
+ mode = " test"
389
+ hint = """
390
+ Hint 1: Take a look at the return type of the function to figure out
391
+ the type for the `basket`.
392
+ Hint 2: Number of fruits should be at least 5. And you have to put
393
+ at least three different types of fruits.
394
+ """
395
+
396
+ [[exercises ]]
397
+ name = " collections4"
398
+ path = " exercises/collections/hashmap2.rs"
399
+ mode = " test"
400
+ hint = """
401
+ Use the `entry()` and `or_insert()` methods of `HashMap` to achieve this.
402
+ Learn more at https://doc.rust-lang.org/stable/book/ch08-03-hash-maps.html#only-inserting-a-value-if-the-key-has-no-value
403
+ """
404
+
359
405
# STRINGS
360
406
361
407
[[exercises ]]
@@ -636,6 +682,23 @@ inside the loop but still in the main thread.
636
682
`child_numbers` should be a clone of the Arc of the numbers instead of a
637
683
thread-local copy of the numbers."""
638
684
685
+ [[exercises ]]
686
+ name = " iterators1"
687
+ path = " exercises/standard_library_types/iterators1.rs"
688
+ mode = " compile"
689
+ hint = """
690
+ Step 1:
691
+ We need to apply something to the collection `my_fav_fruits` before we start to go through
692
+ it. What could that be? Take a look at the struct definition for a vector for inspiration:
693
+ https://doc.rust-lang.org/std/vec/struct.Vec.html.
694
+ Step 2 & step 2.1:
695
+ Very similar to the lines above and below. You've got this!
696
+ Step 3:
697
+ An iterator goes through all elements in a collection, but what if we've run out of
698
+ elements? What should we expect here? If you're stuck, take a look at
699
+ https://doc.rust-lang.org/std/iter/trait.Iterator.html for some ideas.
700
+ """
701
+
639
702
[[exercises ]]
640
703
name = " iterators2"
641
704
path = " exercises/standard_library_types/iterators2.rs"
0 commit comments