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>
impl<I: Iterator> ParMapBuilder<I>
Sourcepub fn par_map<B, F>(self, f: F) -> Map<I, B, F> ⓘ
pub fn par_map<B, F>(self, f: F) -> 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);
Sourcepub fn par_flat_map<U, F>(self, f: F) -> FlatMap<I, U, F> ⓘ
pub fn par_flat_map<U, F>(self, f: F) -> 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");
Sourcepub fn par_packed_map<'a, B, F>(self, nb: usize, f: F) -> PackedMap<'a, B> ⓘ
pub fn par_packed_map<'a, B, F>(self, nb: usize, f: F) -> 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);
Sourcepub fn par_packed_flat_map<'a, U, F>(
self,
nb: usize,
f: F,
) -> PackedFlatMap<'a, U::Item> ⓘ
pub fn par_packed_flat_map<'a, U, F>( self, nb: usize, f: F, ) -> PackedFlatMap<'a, U::Item> ⓘ
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more