Struct par_map::ParMapBuilder[][src]

#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
pub struct ParMapBuilder<I> { /* fields omitted */ }

A builder used to configure the parallele work.

This struct is created by the with_nb_threads() method on ParIter. See its documentation for more.

Methods

impl<I: Iterator> ParMapBuilder<I>
[src]

Important traits for Map<I, B, F>

As ParMap::par_map, but with a custom number of threads

Example

use par_map::ParMap;
let a = [1, 2, 3];
let mut iter = a.iter()
    .cloned()
    .with_nb_threads(2)
    .par_map(|x| 2 * x);
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(4));
assert_eq!(iter.next(), Some(6));
assert_eq!(iter.next(), None);

Important traits for FlatMap<I, U, F>

As ParMap::par_flat_map, but with a custom number of threads

Example

use par_map::ParMap;
let words = ["alpha", "beta", "gamma"];
let merged: String = words.iter()
    .cloned() // as items must be 'static
    .with_nb_threads(2)
    .par_flat_map(|s| s.chars()) // exactly as std::iter::Iterator::flat_map
    .collect();
assert_eq!(merged, "alphabetagamma");

Important traits for PackedMap<'a, B>

As ParMap::par_packed_map, but with a custom number of threads

Example

use par_map::ParMap;
let a = [1, 2, 3];
let mut iter = a.iter()
    .cloned()
    .with_nb_threads(2)
    .par_packed_map(2, |x| 2 * x);
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(4));
assert_eq!(iter.next(), Some(6));
assert_eq!(iter.next(), None);

Important traits for PackedFlatMap<'a, T>

As ParMap::par_packed_flat_map, but with a custom number of threads

Example

use par_map::ParMap;
let words = ["alpha", "beta", "gamma"];
let merged: String = words.iter()
    .cloned()
    .with_nb_threads(2)
    .par_packed_flat_map(2, |s| s.chars())
    .collect();
assert_eq!(merged, "alphabetagamma");

Auto Trait Implementations

impl<I> Send for ParMapBuilder<I> where
    I: Send

impl<I> Sync for ParMapBuilder<I> where
    I: Sync