How it works...
Admittedly, working with multiple threads in Rust is just the same as if we were working on single threads since there are no convenient methods for joining a list of threads or similar. Instead, we can use the power of Rust's iterators to do that in an expressive way. With these functional constructs, the need for for loops can be replaced by a chain of functions that lazily process collections, which makes the code easier to handle and more efficient.
After setting up the project in step 1, we implement a multithreaded function to apply an operation to every chunk. These chunks are simply parts of a vector, and an operation—a simple function that doubles the input variable in this example—can be done with any type of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access