pub trait ParallelExtend<T>where
T: Send,{
// Required method
fn par_extend<I>(&mut self, par_iter: I)
where I: IntoParallelIterator<Item = T>;
}
Expand description
ParallelExtend
extends an existing collection with items from a ParallelIterator
.
§Examples
Implementing ParallelExtend
for your type:
use rayon::prelude::*;
use std::mem;
struct BlackHole {
mass: usize,
}
impl<T: Send> ParallelExtend<T> for BlackHole {
fn par_extend<I>(&mut self, par_iter: I)
where I: IntoParallelIterator<Item = T>
{
let par_iter = par_iter.into_par_iter();
self.mass += par_iter.count() * mem::size_of::<T>();
}
}
let mut bh = BlackHole { mass: 0 };
bh.par_extend(0i32..1000);
assert_eq!(bh.mass, 4000);
bh.par_extend(0i64..10);
assert_eq!(bh.mass, 4080);
Required Methods§
sourcefn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
Extends an instance of the collection with the elements drawn
from the parallel iterator par_iter
.
§Examples
use rayon::prelude::*;
let mut vec = vec![];
vec.par_extend(0..5);
vec.par_extend((0..5).into_par_iter().map(|i| i * i));
assert_eq!(vec, [0, 1, 2, 3, 4, 0, 1, 4, 9, 16]);
Object Safety§
Implementations on Foreign Types§
source§impl ParallelExtend<char> for String
impl ParallelExtend<char> for String
Extends a string with characters from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = char>,
source§impl ParallelExtend<()> for ()
impl ParallelExtend<()> for ()
Collapses all unit items from a parallel iterator into one.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = ()>,
source§impl ParallelExtend<Box<str>> for String
impl ParallelExtend<Box<str>> for String
Extends a string with boxed strings from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)
source§impl ParallelExtend<String> for String
impl ParallelExtend<String> for String
Extends a string with strings from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = String>,
source§impl ParallelExtend<OsString> for OsString
impl ParallelExtend<OsString> for OsString
Extends an OS-string with strings from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = OsString>,
source§impl<'a> ParallelExtend<&'a char> for String
impl<'a> ParallelExtend<&'a char> for String
Extends a string with copied characters from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a char>,
source§impl<'a> ParallelExtend<&'a str> for String
impl<'a> ParallelExtend<&'a str> for String
Extends a string with string slices from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a str>,
source§impl<'a> ParallelExtend<&'a OsStr> for OsString
impl<'a> ParallelExtend<&'a OsStr> for OsString
Extends an OS-string with string slices from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a OsStr>,
source§impl<'a> ParallelExtend<Cow<'a, str>> for String
impl<'a> ParallelExtend<Cow<'a, str>> for String
Extends a string with string slices from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)
source§impl<'a> ParallelExtend<Cow<'a, OsStr>> for OsString
impl<'a> ParallelExtend<Cow<'a, OsStr>> for OsString
Extends an OS-string with string slices from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)
source§impl<'a, K, V> ParallelExtend<(&'a K, &'a V)> for BTreeMap<K, V>
impl<'a, K, V> ParallelExtend<(&'a K, &'a V)> for BTreeMap<K, V>
Extends a B-tree map with copied items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)
source§impl<'a, K, V, S> ParallelExtend<(&'a K, &'a V)> for HashMap<K, V, S>
impl<'a, K, V, S> ParallelExtend<(&'a K, &'a V)> for HashMap<K, V, S>
Extends a hash map with copied items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)
source§impl<'a, T> ParallelExtend<&'a T> for BinaryHeap<T>
impl<'a, T> ParallelExtend<&'a T> for BinaryHeap<T>
Extends a binary heap with copied items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a T>,
source§impl<'a, T> ParallelExtend<&'a T> for BTreeSet<T>
impl<'a, T> ParallelExtend<&'a T> for BTreeSet<T>
Extends a B-tree set with copied items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a T>,
source§impl<'a, T> ParallelExtend<&'a T> for LinkedList<T>
impl<'a, T> ParallelExtend<&'a T> for LinkedList<T>
Extends a linked list with copied items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a T>,
source§impl<'a, T> ParallelExtend<&'a T> for VecDeque<T>
impl<'a, T> ParallelExtend<&'a T> for VecDeque<T>
Extends a deque with copied items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a T>,
source§impl<'a, T> ParallelExtend<&'a T> for Vec<T>
impl<'a, T> ParallelExtend<&'a T> for Vec<T>
Extends a vector with copied items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a T>,
source§impl<'a, T, S> ParallelExtend<&'a T> for HashSet<T, S>
impl<'a, T, S> ParallelExtend<&'a T> for HashSet<T, S>
Extends a hash set with copied items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = &'a T>,
source§impl<A, B, FromA, FromB> ParallelExtend<(A, B)> for (FromA, FromB)
impl<A, B, FromA, FromB> ParallelExtend<(A, B)> for (FromA, FromB)
fn par_extend<I>(&mut self, pi: I)where
I: IntoParallelIterator<Item = (A, B)>,
source§impl<K, V> ParallelExtend<(K, V)> for BTreeMap<K, V>
impl<K, V> ParallelExtend<(K, V)> for BTreeMap<K, V>
Extends a B-tree map with items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = (K, V)>,
source§impl<K, V, S> ParallelExtend<(K, V)> for HashMap<K, V, S>
impl<K, V, S> ParallelExtend<(K, V)> for HashMap<K, V, S>
Extends a hash map with items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = (K, V)>,
source§impl<L, R, A, B> ParallelExtend<Either<L, R>> for (A, B)
impl<L, R, A, B> ParallelExtend<Either<L, R>> for (A, B)
fn par_extend<I>(&mut self, pi: I)where
I: IntoParallelIterator<Item = Either<L, R>>,
source§impl<T> ParallelExtend<T> for BinaryHeap<T>
impl<T> ParallelExtend<T> for BinaryHeap<T>
Extends a binary heap with items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
source§impl<T> ParallelExtend<T> for BTreeSet<T>
impl<T> ParallelExtend<T> for BTreeSet<T>
Extends a B-tree set with items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
source§impl<T> ParallelExtend<T> for LinkedList<T>where
T: Send,
impl<T> ParallelExtend<T> for LinkedList<T>where
T: Send,
Extends a linked list with items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
source§impl<T> ParallelExtend<T> for VecDeque<T>where
T: Send,
impl<T> ParallelExtend<T> for VecDeque<T>where
T: Send,
Extends a deque with items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
source§impl<T> ParallelExtend<T> for Vec<T>where
T: Send,
impl<T> ParallelExtend<T> for Vec<T>where
T: Send,
Extends a vector with items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
source§impl<T, S> ParallelExtend<T> for HashSet<T, S>
impl<T, S> ParallelExtend<T> for HashSet<T, S>
Extends a hash set with items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I)where
I: IntoParallelIterator<Item = T>,
Implementors§
impl<L, R, T> ParallelExtend<T> for Either<L, R>
Either<L, R>
can be extended if both L
and R
are parallel extendable.