pub trait EnumerateParUse: ParUse {
// Required method
fn enumerate(
self,
) -> impl ParUse<Using = Self::Using, Use = Self::Use, Item = (usize, Self::Item), Input = Enumerate<Self::Input>>;
}Expand description
Adds index-value pairs to ParUse pipelines.
This is the ParUse counterpart of parallel enumerate, preserving the
worker-local state while changing each item into (index, item).
§Example
use orx_parallel::*;
let values: Vec<_> = (10..15)
.into_par()
.use_new(|_| ())
.enumerate()
.map(|_, (i, x)| i + x)
.collect();
assert_eq!(values.len(), 5);
assert!(values.contains(&10));
assert!(values.contains(&18));Required Methods§
Sourcefn enumerate(
self,
) -> impl ParUse<Using = Self::Using, Use = Self::Use, Item = (usize, Self::Item), Input = Enumerate<Self::Input>>
fn enumerate( self, ) -> impl ParUse<Using = Self::Using, Use = Self::Use, Item = (usize, Self::Item), Input = Enumerate<Self::Input>>
Transforms each item into (index, item) while keeping worker-local state.
Indices are zero-based and correspond to the iterator order.
§Example
use orx_parallel::*;
let idx_sum: usize = (1..6)
.into_par()
.use_new(|_| ())
.enumerate()
.map(|_, (i, _)| i)
.sum();
assert_eq!(idx_sum, 10);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".