|
|
|
|
|
by dathinab
1204 days ago
|
|
It's a building block allowing more threading abstractions to be build on top of it without using unsafe code. Most importantly it works with references like `&`,`&mut` or `Cow` etc. E.g. in the example below it use used to ad-hoc implemet a typical simple parallel fold
pattern where a collection of data points is chunked and split across num_cpu
threads where each chunk is processed in parallel followed by combining the results. https://play.rust-lang.org/?version=stable&mode=debug&editio... Now in practice for many use cases you want to use more convenient/optimized libraries like rayon for this kinda of things instead of ad-hoc implementing them by hand. But having the necessary primitives to implement it ad-hoc yourself without unsafe code is grate anyway. |
|