[][src]Trait rayon_croissant::ParallelIteratorExt

pub trait ParallelIteratorExt: ParallelIterator {
    fn mapfold_reduce_into<'t, Output, Target, Mapfold, Reduce>(
        self,
        target: &'t mut Target,
        mapfold: Mapfold,
        reduce: Reduce
    ) -> MapfoldReduce<'t, Target, Self, Mapfold, Reduce>
    where
        Output: Send,
        Target: Default + Send + 't,
        Mapfold: Clone + Fn(&mut Target, Self::Item) -> Output,
        Reduce: Clone + Fn(&mut Target, Target)
, { ... } }

Extension methods for rayon's parallel iterators.

Provided methods

fn mapfold_reduce_into<'t, Output, Target, Mapfold, Reduce>(
    self,
    target: &'t mut Target,
    mapfold: Mapfold,
    reduce: Reduce
) -> MapfoldReduce<'t, Target, Self, Mapfold, Reduce> where
    Output: Send,
    Target: Default + Send + 't,
    Mapfold: Clone + Fn(&mut Target, Self::Item) -> Output,
    Reduce: Clone + Fn(&mut Target, Target), 

Applies mapfold to each item of this iterator, producing a new iterator with the Output results, while folding and reducing each intermediate Target to target.

Example

use rayon::prelude::*;
use rayon_croissant::ParallelIteratorExt;

let ingredients = &[
    "baguette",
    "jambon",
    "beurre",
    "fromage",
];

let mut ingredients_indices_with_odd_length = vec![];
let ingredients_lengths = ingredients
    .par_iter()
    .enumerate()
    .mapfold_reduce_into(
        &mut ingredients_indices_with_odd_length,
        |acc, (index, item)| {
            let len = item.len();
            if len % 2 == 1 {
                acc.push(index);
            }
            len
        },
        |left, mut right| left.append(&mut right),
    )
    .collect::<Vec<_>>();

assert_eq!(ingredients_lengths, [8, 6, 6, 7]);
assert_eq!(ingredients_indices_with_odd_length, [3]);
Loading content...

Implementors

impl<Input> ParallelIteratorExt for Input where
    Input: ParallelIterator
[src]

fn mapfold_reduce_into<'t, Output, Target, Mapfold, Reduce>(
    self,
    target: &'t mut Target,
    mapfold: Mapfold,
    reduce: Reduce
) -> MapfoldReduce<'t, Target, Self, Mapfold, Reduce> where
    Output: Send,
    Target: Default + Send + 't,
    Mapfold: Clone + Fn(&mut Target, Self::Item) -> Output,
    Reduce: Clone + Fn(&mut Target, Target), 
[src]

Loading content...