mirror of https://github.com/rust-lang/rustlings
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
986 B
Rust
25 lines
986 B
Rust
// 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` or use the `hint` watch subcommand for a hint.
|
|
|
|
// 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 3
|
|
assert_eq!(my_iterable_fav_fruits.next(), Some(&"raspberry"));
|
|
assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 4
|
|
}
|