2020-08-04 07:57:01 -04:00
|
|
|
// iterators1.rs
|
2021-05-12 11:20:07 -04:00
|
|
|
//
|
2020-08-04 07:57:01 -04:00
|
|
|
// Make me compile by filling in the `???`s
|
|
|
|
//
|
|
|
|
// When performing operations on elements within a collection, iterators are essential.
|
2021-05-12 11:20:07 -04:00
|
|
|
// This module helps you get familiar with the structure of using an iterator and
|
2020-08-04 07:57:01 -04:00
|
|
|
// how to go through elements within an iterable collection.
|
2021-05-12 11:20:07 -04:00
|
|
|
//
|
2022-07-14 12:29:09 -04:00
|
|
|
// Execute `rustlings hint iterators1` or use the `hint` watch subcommand for a hint.
|
2020-08-04 07:57:01 -04:00
|
|
|
|
|
|
|
// I AM NOT DONE
|
|
|
|
|
2023-02-26 11:28:24 -05:00
|
|
|
fn main () {
|
2020-08-04 07:57:01 -04:00
|
|
|
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 3
|
2022-03-30 07:27:52 -04:00
|
|
|
assert_eq!(my_iterable_fav_fruits.next(), Some(&"raspberry"));
|
|
|
|
assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 4
|
2020-08-04 07:57:01 -04:00
|
|
|
}
|