pub struct MutSliceParallelSource<'data, T> { /* private fields */ }Expand description
A parallel source over a mutable slice. This struct is created by
the par_iter_mut() method
on IntoExactParallelRefMutSource.
You most likely won’t need to interact with this struct directly, as it
implements the ExactParallelSource and
ExactParallelSourceExt traits, but it is
nonetheless public because of the must_use annotation.
See also SliceParallelSource.
let mut values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let iter: MutSliceParallelSource<_> = values.par_iter_mut();
iter.with_thread_pool(&mut thread_pool)
.for_each(|x| *x *= 2);
assert_eq!(values, [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]);The slice element type must be Send, so the following example doesn’t
compile.
ⓘ
use std::rc::Rc;
let mut values = [Rc::new(1), Rc::new(2), Rc::new(3), Rc::new(4)];
let iter: MutSliceParallelSource<_> = values.par_iter_mut();Trait Implementations§
Source§impl<'data, T: Send> ExactParallelSource for MutSliceParallelSource<'data, T>
impl<'data, T: Send> ExactParallelSource for MutSliceParallelSource<'data, T>
Source§type Item = &'data mut T
type Item = &'data mut T
The type of items that this parallel source produces. Read more
Source§fn exact_descriptor(
self,
) -> impl ExactSourceDescriptor<Item = Self::Item> + Sync
fn exact_descriptor( self, ) -> impl ExactSourceDescriptor<Item = Self::Item> + Sync
Returns an object that describes how to fetch items from this source.
Auto Trait Implementations§
impl<'data, T> !UnwindSafe for MutSliceParallelSource<'data, T>
impl<'data, T> Forget for MutSliceParallelSource<'data, T>
impl<'data, T> Freeze for MutSliceParallelSource<'data, T>
impl<'data, T> Move for MutSliceParallelSource<'data, T>
impl<'data, T> RefUnwindSafe for MutSliceParallelSource<'data, T>where
&'data mut [T]: RefUnwindSafe,
impl<'data, T> Send for MutSliceParallelSource<'data, T>
impl<'data, T> Sync for MutSliceParallelSource<'data, T>
impl<'data, T> Unpin for MutSliceParallelSource<'data, T>
impl<'data, T> UnsafeUnpin for MutSliceParallelSource<'data, T>where
&'data mut [T]: UnsafeUnpin,
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
Source§impl<T> ExactParallelSourceExt for Twhere
T: ExactParallelSource,
impl<T> ExactParallelSourceExt for Twhere
T: ExactParallelSource,
Source§fn array_windows<const N: usize>(self) -> ArrayWindows<Self, N>where
Self: RewindableSource,
fn array_windows<const N: usize>(self) -> ArrayWindows<Self, N>where
Self: RewindableSource,
Returns a parallel source that produces overlapping arrays of
N
contiguous items from this source. Read moreSource§fn chain<T: ExactParallelSource<Item = Self::Item>>(
self,
next: T,
) -> Chain<Self, T>
fn chain<T: ExactParallelSource<Item = Self::Item>>( self, next: T, ) -> Chain<Self, T>
Returns a parallel source that produces items from this source followed
by items from the next source. Read more
Source§fn cycle(self, n: usize) -> Cycle<Self>where
Self: RewindableSource,
fn cycle(self, n: usize) -> Cycle<Self>where
Self: RewindableSource,
Returns a parallel source that produces items from this source the given
number of times. Read more
Source§fn enumerate(self) -> Enumerate<Self>
fn enumerate(self) -> Enumerate<Self>
Returns a parallel source that produces pairs of (index, item) for the
items of this source. Read more
Source§fn filter<F>(self, f: F) -> FilterExact<Self, F>
fn filter<F>(self, f: F) -> FilterExact<Self, F>
Source§fn filter_map<T, F>(self, f: F) -> FilterMapExact<Self, F>
fn filter_map<T, F>(self, f: F) -> FilterMapExact<Self, F>
Source§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Runs the function
f on each item of this source in a pass-through
manner, returning a parallel source producing the original items. Read moreSource§fn map<T, F>(self, f: F) -> MapSource<Self, F>
fn map<T, F>(self, f: F) -> MapSource<Self, F>
Applies the function
f to each item of this source, returning a
parallel source producing the mapped items. Read moreSource§fn map_init<I, Init, T, F>(self, init: Init, f: F) -> MapInit<Self, Init, F>
fn map_init<I, Init, T, F>(self, init: Init, f: F) -> MapInit<Self, Init, F>
Applies the function
f to each item of this source, together with a
per-thread mutable value returned by init, and returns a parallel
source producing the mapped items. Read moreSource§fn rev(self) -> Rev<Self>
fn rev(self) -> Rev<Self>
Returns a parallel source that produces items from this source in
reverse order. Read more
Source§fn skip(self, n: usize) -> Skip<Self>
fn skip(self, n: usize) -> Skip<Self>
Returns a parallel source that skips the first
n items from this
source, or all the items if this source has fewer than n items, and
produces the remaining items. Read moreSource§fn skip_exact(self, n: usize) -> SkipExact<Self>
fn skip_exact(self, n: usize) -> SkipExact<Self>
Returns a parallel source that skips the first
n items from this
source, panicking if this source has fewer than n items, and produces
the remaining items. Read moreSource§fn step_by(self, n: usize) -> StepBy<Self>
fn step_by(self, n: usize) -> StepBy<Self>
Returns a parallel source that produces every
n-th item from this
source, starting with the first one. Read moreSource§fn take(self, n: usize) -> Take<Self>
fn take(self, n: usize) -> Take<Self>
Returns a parallel source that produces the first
n items from this
source, or all the items if this source has fewer than n items. Read moreSource§fn take_exact(self, n: usize) -> TakeExact<Self>
fn take_exact(self, n: usize) -> TakeExact<Self>
Returns a parallel source that produces the first
n items from this
source, panicking if this source has fewer than n items. Read moreSource§fn update<F>(self, f: F) -> Update<Self, F>
fn update<F>(self, f: F) -> Update<Self, F>
Applies the function
f to each item of this source, returning a
parallel source producing the updated items. Read moreSource§fn with_thread_pool<T: GenericThreadPool>(
self,
thread_pool: T,
) -> BaseExactParallelIterator<T, Self>
fn with_thread_pool<T: GenericThreadPool>( self, thread_pool: T, ) -> BaseExactParallelIterator<T, Self>
Attaches the given
GenericThreadPool to this ExactParallelSource
and obtain a ParallelIterator. Read more