January 2018
Beginner to intermediate
454 pages
10h 8m
English
The Rust documentation describes an iterator as Composable external iteration.
They're used a lot in idiomatic Rust code on collection types (slice, Vec, HashMap, and so on) so it's very important to learn to master them. This code will allow us to have a nice introduction. Let's look at the code now:
slice.iter().map(|highscore| highscore.to_string()). collect::<Vec<String>>().join(" ")
This is quite difficult to read and understand for the moment, so let's rewrite it as follows:
slice.iter()
.map(|highscore| highscore.to_string())
.collect::<Vec<String>>()
.join(" ")Better (or at least more readable!). Now let's go step by step, as follows:
slice.iter()
Here, we create an iterator from our slice. A really important and ...
Read now
Unlock full access