pub trait ParDrain: ConcurrentDrainableOverSlice {
// Provided method
fn par_drain<R>(
&mut self,
range: R,
) -> ParIter<<Self as ConcurrentDrainableOverSlice>::DrainingIter<'_>, Id<Self::Item>>
where R: RangeBounds<usize> { ... }
}Expand description
Adds parallel draining to slice-based drainable collections.
Sequential counterpart: draining methods such as Vec::drain.
Provided Methods§
Sourcefn par_drain<R>(
&mut self,
range: R,
) -> ParIter<<Self as ConcurrentDrainableOverSlice>::DrainingIter<'_>, Id<Self::Item>>where
R: RangeBounds<usize>,
fn par_drain<R>(
&mut self,
range: R,
) -> ParIter<<Self as ConcurrentDrainableOverSlice>::DrainingIter<'_>, Id<Self::Item>>where
R: RangeBounds<usize>,
Drains the specified range and returns a parallel iterator over removed items.
§Example
use orx_parallel::*;
let mut values = vec![0i32, 1, 2, 3, 4, 5];
let drained_sum: i32 = ParDrain::par_drain(&mut values, 0..3).sum();
assert_eq!(drained_sum, 3);
assert_eq!(values, vec![3, 4, 5]);§Panics
Panics if range is invalid for the underlying collection.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".