1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-07-13 01:20:42 +02:00
Files
.github
.vscode
exercises
clippy
conversions
enums
error_handling
functions
generics
hashmaps
if
intro
iterators
README.md
iterators1.rs
iterators2.rs
iterators3.rs
iterators4.rs
iterators5.rs
lifetimes
macros
modules
move_semantics
options
primitive_types
smart_pointers
strings
structs
tests
threads
traits
variables
vecs
README.md
quiz1.rs
quiz2.rs
quiz3.rs
src
tests
.all-contributorsrc
.editorconfig
.gitignore
.gitpod.yml
.replit
AUTHORS.md
CHANGELOG.md
CONTRIBUTING.md
Cargo.lock
Cargo.toml
LICENSE
README.md
flake.lock
flake.nix
info.toml
install.ps1
install.sh
shell.nix
rustlings/exercises/iterators/iterators1.rs

25 lines
986 B
Rust
Raw Normal View History

2020-08-04 12:57:01 +01:00
// iterators1.rs
//
2020-08-04 12:57:01 +01:00
// 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
2020-08-04 12:57:01 +01:00
// how to go through elements within an iterable collection.
//
2022-07-14 18:29:09 +02:00
// Execute `rustlings hint iterators1` or use the `hint` watch subcommand for a hint.
2020-08-04 12:57:01 +01:00
// 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
2020-08-04 12:57:01 +01:00
}