[][src]Trait asparit::IntoParallelRefIterator

pub trait IntoParallelRefIterator<'a> {
    type Iter: ParallelIterator<'a, Item = Self::Item>;
    type Item: Send + 'a;
    pub fn par_iter(&'a self) -> Self::Iter;
}

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.

Associated Types

type Iter: ParallelIterator<'a, Item = Self::Item>

The type of the parallel iterator that will be returned.

type Item: Send + 'a

The type of item that the parallel iterator will produce. This will typically be an &'a T reference type.

Loading content...

Required methods

pub fn par_iter(&'a self) -> Self::Iter

Converts self into a parallel iterator.

Examples

use asparit::*;

let v: Vec<_> = (0..100).collect();
assert_eq!(v.par_iter().sum::<i32>().exec(), 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)).exec());
Loading content...

Implementors

impl<'a, I: ?Sized> IntoParallelRefIterator<'a> for I where
    I: 'a,
    &'a I: IntoParallelIterator<'a>, 
[src]

type Iter = <&'a I as IntoParallelIterator<'a>>::Iter

type Item = <&'a I as IntoParallelIterator<'a>>::Item

Loading content...