summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorfmoko <mokou@posteo.de>2020-09-18 15:23:28 +0200
committerGitHub <noreply@github.com>2020-09-18 15:23:28 +0200
commit0f16463794f86d48fa368b3bd2a5504d5ffe8cbf (patch)
tree1edb5975d0be6ca7296be3c0b48eac51b5f485f5 /exercises
parent3286c5ec19ea5fb7ded81d047da5f8594108a490 (diff)
parent8ff5fde88edb8f24253d7dc894501473cf701dbc (diff)
Merge pull request #489 from mukundbhudia/iterators1
Diffstat (limited to 'exercises')
-rw-r--r--exercises/standard_library_types/README.md2
-rw-r--r--exercises/standard_library_types/iterators1.rs24
2 files changed, 24 insertions, 2 deletions
diff --git a/exercises/standard_library_types/README.md b/exercises/standard_library_types/README.md
index 36b30c1..8b53dd8 100644
--- a/exercises/standard_library_types/README.md
+++ b/exercises/standard_library_types/README.md
@@ -3,5 +3,3 @@ For the Box exercise check out the chapter [Using Box to Point to Data on the He
For the Arc exercise check out the chapter [Shared-State Concurrency](https://doc.rust-lang.org/book/ch16-03-shared-state.html) of the Rust Book.
For the Iterator exercise check out the chapters [Iterator](https://doc.rust-lang.org/book/ch13-02-iterators.html) of the Rust Book and the [Iterator documentation](https://doc.rust-lang.org/stable/std/iter/).
-Do not adjust your monitors-- iterators1.rs is indeed missing. Iterators is a challenging topic, so we're leaving space for a simpler exercise!
-
diff --git a/exercises/standard_library_types/iterators1.rs b/exercises/standard_library_types/iterators1.rs
new file mode 100644
index 0000000..3fd519d
--- /dev/null
+++ b/exercises/standard_library_types/iterators1.rs
@@ -0,0 +1,24 @@
+// iterators1.rs
+//
+// Make me compile by filling in the `???`s
+//
+// When performing operations on elements within a collection, iterators are essential.
+// This module helps you get familiar with the structure of using an iterator and
+// how to go through elements within an iterable collection.
+//
+// Execute `rustlings hint iterators1` for hints :D
+
+// I AM NOT DONE
+
+fn main () {
+ let my_fav_fruits = vec!["banana", "custard apple", "avocado", "peach", "raspberry"];
+
+ let mut my_iterable_fav_fruits = ???; // TODO: Step 1
+
+ assert_eq!(my_iterable_fav_fruits.next(), Some(&"banana"));
+ assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 2
+ assert_eq!(my_iterable_fav_fruits.next(), Some(&"avocado"));
+ assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 2.1
+ assert_eq!(my_iterable_fav_fruits.next(), Some(&"raspberry"));
+ assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 3
+}