pub trait ParallelDrainableOverSlice: ConcurrentDrainableOverSlice {
// Provided method
fn par_drain<R>(
&mut self,
range: R,
) -> Par<<Self as ConcurrentDrainableOverSlice>::DrainingIter<'_>, DefaultRunner>
where R: RangeBounds<usize> { ... }
}
Expand description
A type which can create a parallel draining iterator over any of its sub-slices.
- Created draining iterator takes out and returns all elements of the slice defined by the
range
. - The slice defined by this
range
will be removed from the original collection.
If the iterator is dropped before being fully consumed, it drops the remaining removed elements.
If the complete range is provided (..
or 0..self.len()
), self will remain empty.
§Examples
use orx_parallel::*;
let mut v = vec![1, 2, 3];
let u: Vec<_> = v.par_drain(1..).num_threads(2).collect();
assert_eq!(v, &[1]);
assert_eq!(u, &[2, 3]);
Provided Methods§
Sourcefn par_drain<R>(
&mut self,
range: R,
) -> Par<<Self as ConcurrentDrainableOverSlice>::DrainingIter<'_>, DefaultRunner>where
R: RangeBounds<usize>,
fn par_drain<R>(
&mut self,
range: R,
) -> Par<<Self as ConcurrentDrainableOverSlice>::DrainingIter<'_>, DefaultRunner>where
R: RangeBounds<usize>,
Creates a parallel draining iterator over the slice defined by the given range
.
- Created draining iterator takes out and returns all elements of the slice defined by the
range
. - The slice defined by this
range
will be removed from the original collection.
If the iterator is dropped before being fully consumed, it drops the remaining removed elements.
If the complete range is provided (..
or 0..self.len()
), self will remain empty.
§Examples
use orx_parallel::*;
let mut v = vec![1, 2, 3];
let u: Vec<_> = v.par_drain(1..).num_threads(2).collect();
assert_eq!(v, &[1]);
assert_eq!(u, &[2, 3]);
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.