Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Rust Standard Library Cookbook

You're reading from   Rust Standard Library Cookbook Over 75 recipes to leverage the power of Rust

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher Packt
ISBN-13 9781788623926
Length 360 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Jan Hohenheim Jan Hohenheim
Author Profile Icon Jan Hohenheim
Jan Hohenheim
Daniel Durante Daniel Durante
Author Profile Icon Daniel Durante
Daniel Durante
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Learning the Basics FREE CHAPTER 2. Working with Collections 3. Handling Files and the Filesystem 4. Serialization 5. Advanced Data Structures 6. Handling Errors 7. Parallelism and Rayon 8. Working with Futures 9. Networking 10. Using Experimental Nightly Features 11. Other Books You May Enjoy

How it works...

rayon implements the trait ParallelIterator for every type that implements its standard library equivalent Iterator, which we got to know in Chapter 2, Working with Collections; Access Collections as iterators. In fact, you can use all the knowledge from said recipe again here. The methods provided by the ParallelIterator trait are nearly the same as the ones provided by Iterator, so in virtually all cases where you notice an iterator operation taking too long and bottlenecking you, you can simply replace .iter() with .par_iter()[10]. Similarly, for moving iterators, you can use .into_par_iter() instead of .into_iter().

rayon handles all the tedious work for you, as it automatically distributes the work evenly between all of your available cores. Just keep in mind that despite this magic, you're still dealing with parallelism here, so you have no guarantees about the order in which the items in your iterator are going to be handled, as evidenced by line...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image