While in the previous recipe we discussed implementing a custom iterator, it's now time to make use of the functions they provide. Iterators can transform, filter, reduce, or simply convert the underlying elements in a single go, thereby making it a very efficient endeavor.
Filtering and transforming sequences efficiently
Getting ready
First, create a new project using cargo new iteration --lib and add the following to the newly created Cargo.toml file in the project's directory:
[dev-dependencies]
rand = "^0.5"
This adds a dependency to the rand (https://github.com/rust-random/rand) crate to the project, which will be installed upon running cargo test the first time. Open the entire project (or the src...