From 9642f5a3f686270a4f8f6ba969919ddbbc4f7fdd Mon Sep 17 00:00:00 2001 From: Mukund Bhudia Date: Tue, 4 Aug 2020 12:57:01 +0100 Subject: feat: Added iterators1.rs exercise --- exercises/standard_library_types/README.md | 2 -- exercises/standard_library_types/iterators1.rs | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 exercises/standard_library_types/iterators1.rs (limited to 'exercises') 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 +} -- cgit v1.2.3