Struct ParMapBuilder

Source
pub struct ParMapBuilder<I> { /* private fields */ }
Expand description

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.

Implementations§

Source§

impl<I: Iterator> ParMapBuilder<I>

Source

pub fn par_map<B, F>(self, f: F) -> Map<I, B, F>
where F: Sync + Send + 'static + Fn(I::Item) -> B, B: Send + 'static, I::Item: Send + 'static,

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);
Source

pub fn par_flat_map<U, F>(self, f: F) -> FlatMap<I, U, F>
where F: Sync + Send + 'static + Fn(I::Item) -> U, U: IntoIterator, U::Item: Send + 'static, I::Item: Send + 'static,

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");
Source

pub fn par_packed_map<'a, B, F>(self, nb: usize, f: F) -> PackedMap<'a, B>
where F: Sync + Send + 'static + Fn(I::Item) -> B, B: Send + 'static, I::Item: Send + 'static, Self: 'a,

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);
Source

pub fn par_packed_flat_map<'a, U, F>( self, nb: usize, f: F, ) -> PackedFlatMap<'a, U::Item>
where F: Sync + Send + 'static + Fn(I::Item) -> U, U: IntoIterator + 'a, U::Item: Send + 'static, I::Item: Send + 'static, Self: 'a,

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> Freeze for ParMapBuilder<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for ParMapBuilder<I>
where I: RefUnwindSafe,

§

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

§

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

§

impl<I> Unpin for ParMapBuilder<I>
where I: Unpin,

§

impl<I> UnwindSafe for ParMapBuilder<I>
where I: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.