Trait maybe_rayon::iter::IntoParallelRefIterator
source · pub trait IntoParallelRefIterator<'data> {
type Iter: ParallelIterator<Item = Self::Item>;
type Item: Send + 'data;
fn par_iter(&'data self) -> Self::Iter;
}
Expand description
IntoParallelRefIterator
implements the conversion to a
ParallelIterator
, providing shared references to the data.
This is a parallel version of the iter()
method
defined by various collections.
This trait is automatically implemented
for I where &I: IntoParallelIterator
. In most cases, users
will want to implement IntoParallelIterator
rather than implement
this trait directly.
Required Associated Types§
sourcetype Iter: ParallelIterator<Item = Self::Item>
type Iter: ParallelIterator<Item = Self::Item>
The type of the parallel iterator that will be returned.
Required Methods§
sourcefn par_iter(&'data self) -> Self::Iter
fn par_iter(&'data self) -> Self::Iter
Converts self
into a parallel iterator.
Examples
use rayon::prelude::*;
let v: Vec<_> = (0..100).collect();
assert_eq!(v.par_iter().sum::<i32>(), 100 * 99 / 2);
// `v.par_iter()` is shorthand for `(&v).into_par_iter()`,
// producing the exact same references.
assert!(v.par_iter().zip(&v)
.all(|(a, b)| std::ptr::eq(a, b)));