Name Description Size
blocks.rs 3986
chain.rs 6887
chunks.rs 5368
cloned.rs 4951
collect
copied.rs 4937
empty.rs 2165
enumerate.rs 3507
extend.rs 15905
filter.rs 3513
filter_map.rs 3708
find.rs 2727
find_first_last
flat_map.rs 3952
flat_map_iter.rs 3753
flatten.rs 3342
flatten_iter.rs 3129
fold.rs 7169
fold_chunks.rs 6409
fold_chunks_with.rs 6367
for_each.rs 1416
from_par_iter.rs 8161
inspect.rs 6103
interleave.rs 8996
interleave_shortest.rs 2298
intersperse.rs 10270
len.rs 6238
map.rs 5972
map_with.rs 14235
mod.rs Traits for writing parallel programs using an iterator-style interface You will rarely need to interact with this module directly unless you have need to name one of the iterator types. Parallel iterators make it easy to write iterator-like chains that execute in parallel: typically all you have to do is convert the first `.iter()` (or `iter_mut()`, `into_iter()`, etc) method into `par_iter()` (or `par_iter_mut()`, `into_par_iter()`, etc). For example, to compute the sum of the squares of a sequence of integers, one might write: ```rust use rayon::prelude::*; fn sum_of_squares(input: &[i32]) -> i32 { input.par_iter() .map(|i| i * i) .sum() } ``` Or, to increment all the integers in a slice, you could write: ```rust use rayon::prelude::*; fn increment_all(input: &mut [i32]) { input.par_iter_mut() .for_each(|p| *p += 1); } ``` To use parallel iterators, first import the traits by adding something like `use rayon::prelude::*` to your module. You can then call `par_iter`, `par_iter_mut`, or `into_par_iter` to get a parallel iterator. Like a [regular iterator][], parallel iterators work by first constructing a computation and then executing it. In addition to `par_iter()` and friends, some types offer other ways to create (or consume) parallel iterators: - Slices (`&[T]`, `&mut [T]`) offer methods like `par_split` and `par_windows`, as well as various parallel sorting operations. See [the `ParallelSlice` trait] for the full list. - Strings (`&str`) offer methods like `par_split` and `par_lines`. See [the `ParallelString` trait] for the full list. - Various collections offer [`par_extend`], which grows a collection given a parallel iterator. (If you don't have a collection to extend, you can use [`collect()`] to create a new one from scratch.) [the `ParallelSlice` trait]: ../slice/trait.ParallelSlice.html [the `ParallelString` trait]: ../str/trait.ParallelString.html [`par_extend`]: trait.ParallelExtend.html [`collect()`]: trait.ParallelIterator.html#method.collect To see the full range of methods available on parallel iterators, check out the [`ParallelIterator`] and [`IndexedParallelIterator`] traits. If you'd like to build a custom parallel iterator, or to write your own combinator, then check out the [split] function and the [plumbing] module. [regular iterator]: https://doc.rust-lang.org/std/iter/trait.Iterator.html [`ParallelIterator`]: trait.ParallelIterator.html [`IndexedParallelIterator`]: trait.IndexedParallelIterator.html [split]: fn.split.html [plumbing]: plumbing/index.html Note: Several of the `ParallelIterator` methods rely on a `Try` trait which has been deliberately obscured from the public API. This trait is intended to mirror the unstable `std::ops::Try` with implementations for `Option` and `Result`, where `Some`/`Ok` values will let those iterators continue, but `None`/`Err` values will exit early. A note about object safety: It is currently _not_ possible to wrap a `ParallelIterator` (or any trait that depends on it) using a `Box<dyn ParallelIterator>` or other kind of dynamic allocation, because `ParallelIterator` is **not object-safe**. (This keeps the implementation simpler and allows extra optimizations.) 122192
multizip.rs 8955
noop.rs 1074
once.rs 1659
panic_fuse.rs 7703
par_bridge.rs 5685
plumbing
positions.rs 3472
product.rs 2229
reduce.rs 2315
repeat.rs 5547
rev.rs 2806
skip.rs 2441
skip_any.rs 3318
skip_any_while.rs 4136
splitter.rs 5519
step_by.rs 3430
sum.rs 2010
take.rs 2010
take_any.rs 3406
take_any_while.rs 4198
test.rs 63527
try_fold.rs 7536
try_reduce.rs 3244
try_reduce_with.rs 3410
unzip.rs 13584
update.rs 7668
walk_tree.rs 13866
while_some.rs 3758
zip.rs 3920
zip_eq.rs 1752