- Create a Rust project to work on during this chapter with cargo new chapter-seven.
- Navigate into the newly-created chapter-seven folder. For the rest of this chapter, we will assume that your command line is currently in this directory.
- Open the Cargo.toml file that has been generated for you.
- Under [dependencies], add the following line:
rayon = "1.0.0"
If you want, you can go to rayon's crates.io page (https://crates.io/crates/rayon) to check for the newest version and use that one instead.
- Inside the src folder, create a new folder called bin.
- Delete the generated lib.rs file, as we are not creating a library.
- In the src/bin folder, create a file called par_iter.rs.
- Add the following code and run it with cargo run --bin par_iter:
1 extern crate rayon;
2 use rayon::prelude::*;
3
4 fn main() {
5 let legend = "Did you ever hear the tragedy of Darth Plagueis
The Wise?";
6 let words: Vec<_> = legend.split_whitespace...