pub trait ParallelIterator: Sized + Send {
type Item: Send;
Show 76 methods
// Required methods
fn drive<C, R>(self, consumer: C) -> R
where C: Consumer<Self::Item, Result = R> + Send + Sync,
R: Send;
fn seq_items(self) -> Vec<Self::Item>;
// Provided methods
fn seq_iter(self) -> impl Iterator<Item = Self::Item> { ... }
fn seq_try_fold<T, B, F>(self, init: T, fold_fn: F) -> ControlFlow<B, T>
where F: FnMut(T, Self::Item) -> ControlFlow<B, T> { ... }
fn seq_fold<T, F>(self, init: T, fold_fn: F) -> T
where F: FnMut(T, Self::Item) -> T { ... }
fn seq_items_window(
self,
skip: usize,
take: Option<usize>,
) -> Vec<Self::Item> { ... }
fn seq_items_reversed(self) -> Vec<Self::Item> { ... }
fn seq_items_reversed_prefix(self, count: usize) -> Vec<Self::Item> { ... }
fn map<F, R>(self, map_fn: F) -> Map<Self, F>
where F: Fn(Self::Item) -> R + Send + Sync + Clone,
R: Send { ... }
fn map_with<T, F, R>(self, init: T, map_fn: F) -> MapWith<Self, T, F>
where T: Send + Clone,
F: Fn(&mut T, Self::Item) -> R + Send + Sync + Clone,
R: Send + Sync + 'static { ... }
fn map_init<Init, T, F, R>(
self,
init: Init,
map_fn: F,
) -> MapInit<Self, Init, F>
where Init: Fn() -> T + Send + Sync + Clone,
T: Send,
F: Fn(&mut T, Self::Item) -> R + Send + Sync + Clone,
R: Send + Sync + 'static { ... }
fn update<F>(self, update_fn: F) -> Update<Self, F>
where F: Fn(&mut Self::Item) + Send + Sync + Clone,
Self::Item: Sync + 'static { ... }
fn filter<F>(self, filter_fn: F) -> Filter<Self, F>
where F: Fn(&Self::Item) -> bool + Send + Sync + Clone { ... }
fn inspect<F>(self, inspect_fn: F) -> Inspect<Self, F>
where F: Fn(&Self::Item) + Send + Sync + Clone,
Self::Item: Sync { ... }
fn panic_fuse(self) -> PanicFuse<Self>
where Self::Item: Sync { ... }
fn filter_map<F, R>(self, filter_map_fn: F) -> FilterMap<Self, F>
where F: Fn(Self::Item) -> Option<R> + Send + Sync + Clone,
R: Send + Sync + 'static { ... }
fn while_some<T>(self) -> WhileSome<Self>
where Self: ParallelIterator<Item = Option<T>>,
T: Send + Sync + 'static { ... }
fn flat_map<F, U>(self, flat_map_fn: F) -> FlatMap<Self, F>
where F: Fn(Self::Item) -> U + Send + Sync + Clone,
U: IntoIterator,
<U as IntoIterator>::Item: Send + Sync + 'static { ... }
fn flat_map_iter<F, U>(self, flat_map_fn: F) -> FlatMap<Self, F>
where F: Fn(Self::Item) -> U + Send + Sync + Clone,
U: IntoIterator,
<U as IntoIterator>::Item: Send + Sync + 'static { ... }
fn flatten(self) -> Flatten<Self>
where Self::Item: IntoIterator,
<Self::Item as IntoIterator>::Item: Send + Sync + 'static { ... }
fn flatten_iter(self) -> Flatten<Self>
where Self::Item: IntoIterator,
<Self::Item as IntoIterator>::Item: Send + Sync + 'static { ... }
fn enumerate(self) -> Enumerate<Self>
where Self::Item: Sync + 'static { ... }
fn zip<J>(self, other: J) -> Zip<Self, J>
where J: ParallelIterator,
Self::Item: Sync + 'static,
<J as ParallelIterator>::Item: Sync + 'static { ... }
fn zip_eq<J>(self, other: J) -> ZipEq<Self, J>
where J: ParallelIterator,
Self::Item: Sync + 'static,
<J as ParallelIterator>::Item: Sync + 'static { ... }
fn take(self, count: usize) -> Take<Self>
where Self::Item: Sync + 'static { ... }
fn take_any(self, count: usize) -> Take<Self>
where Self::Item: Sync + 'static { ... }
fn skip(self, count: usize) -> Skip<Self>
where Self::Item: Sync + 'static { ... }
fn skip_any(self, count: usize) -> Skip<Self>
where Self::Item: Sync + 'static { ... }
fn take_any_while<F>(self, predicate: F) -> TakeAnyWhile<Self, F>
where F: Fn(&Self::Item) -> bool + Send + Sync + Clone,
Self::Item: Sync + 'static { ... }
fn skip_any_while<F>(self, predicate: F) -> SkipAnyWhile<Self, F>
where F: Fn(&Self::Item) -> bool + Send + Sync + Clone,
Self::Item: Sync + 'static { ... }
fn chain<J>(self, other: J) -> Chain<Self, J>
where J: ParallelIterator<Item = Self::Item>,
Self::Item: Sync + 'static { ... }
fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
where Self::Item: Clone + Sync + 'static { ... }
fn rev(self) -> Rev<Self>
where Self::Item: Sync + 'static { ... }
fn chunks(self, chunk_size: usize) -> Chunks<Self>
where Self::Item: Sync + 'static { ... }
fn copied<'data, T>(self) -> Copied<Self>
where Self: ParallelIterator<Item = &'data T>,
T: Copy + Send + Sync + 'data + 'static { ... }
fn cloned<'data, T>(self) -> Cloned<Self>
where Self: ParallelIterator<Item = &'data T>,
T: Clone + Send + Sync + 'data + 'static { ... }
fn reduce<F>(self, reduce_fn: F) -> Option<Self::Item>
where F: Fn(Self::Item, Self::Item) -> Self::Item + Send + Sync + Clone,
Self::Item: Clone + Sync { ... }
fn fold<T, F>(self, init: T, fold_fn: F) -> T
where T: Send + Sync + Clone,
F: Fn(T, Self::Item) -> T + Send + Sync + Clone,
Self::Item: Sync { ... }
fn collect<C>(self) -> C
where C: ParallelExtend<Self::Item> + Default + Send { ... }
fn collect_vec_list(self) -> LinkedList<Vec<Self::Item>> { ... }
fn partition<C, F>(self, predicate: F) -> (C, C)
where C: FromIterator<Self::Item> + Send,
F: Fn(&Self::Item) -> bool + Send + Sync + Clone,
Self::Item: Sync + 'static { ... }
fn partition_map<A, B, P, L, R>(self, predicate: P) -> (A, B)
where A: Default + Extend<L> + Send,
B: Default + Extend<R> + Send,
P: Fn(Self::Item) -> Either<L, R> + Send + Sync + Clone,
L: Send,
R: Send { ... }
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
where Self: ParallelIterator<Item = (A, B)>,
FromA: Default + Extend<A> + Send,
FromB: Default + Extend<B> + Send,
A: Send,
B: Send { ... }
fn sequential(self) -> SequentialAdapter<Self> { ... }
fn count(self) -> usize
where Self::Item: Sync { ... }
fn find_first<F>(self, predicate: F) -> Option<Self::Item>
where F: Fn(&Self::Item) -> bool + Send + Sync + Clone,
Self::Item: Sync { ... }
fn find_last<F>(self, predicate: F) -> Option<Self::Item>
where F: Fn(&Self::Item) -> bool + Send + Sync + Clone { ... }
fn position_first<F>(self, predicate: F) -> Option<usize>
where F: Fn(Self::Item) -> bool + Send + Sync + Clone { ... }
fn position_any<F>(self, predicate: F) -> Option<usize>
where F: Fn(Self::Item) -> bool + Send + Sync + Clone { ... }
fn position_last<F>(self, predicate: F) -> Option<usize>
where F: Fn(Self::Item) -> bool + Send + Sync + Clone { ... }
fn positions<F>(self, predicate: F) -> Positions<Self, F>
where F: Fn(Self::Item) -> bool + Send + Sync + Clone { ... }
fn find_map_first<F, R>(self, map_fn: F) -> Option<R>
where F: Fn(Self::Item) -> Option<R> + Send + Sync + Clone,
R: Send { ... }
fn find_map_any<F, R>(self, map_fn: F) -> Option<R>
where F: Fn(Self::Item) -> Option<R> + Send + Sync + Clone,
R: Send { ... }
fn find_map_last<F, R>(self, map_fn: F) -> Option<R>
where F: Fn(Self::Item) -> Option<R> + Send + Sync + Clone,
R: Send { ... }
fn any<F>(self, predicate: F) -> bool
where F: Fn(&Self::Item) -> bool + Send + Sync + Clone,
Self::Item: Sync { ... }
fn all<F>(self, predicate: F) -> bool
where F: Fn(&Self::Item) -> bool + Send + Sync + Clone,
Self::Item: Sync { ... }
fn for_each<F>(self, op: F)
where F: Fn(Self::Item) + Send + Sync + Clone { ... }
fn for_each_with<T, F>(self, init: T, op: F)
where T: Send + Clone,
F: Fn(&mut T, Self::Item) + Send + Sync + Clone { ... }
fn for_each_init<Init, T, F>(self, init: Init, op: F)
where Init: Fn() -> T + Send + Sync + Clone,
T: Send,
F: Fn(&mut T, Self::Item) + Send + Sync + Clone { ... }
fn try_for_each<F, E>(self, op: F) -> Result<(), E>
where F: Fn(Self::Item) -> Result<(), E> + Send + Sync + Clone,
E: Send { ... }
fn try_for_each_with<T, F, E>(self, init: T, op: F) -> Result<(), E>
where T: Send + Clone,
F: Fn(&mut T, Self::Item) -> Result<(), E> + Send + Sync + Clone,
E: Send { ... }
fn try_for_each_init<Init, T, F, E>(
self,
init: Init,
op: F,
) -> Result<(), E>
where Init: Fn() -> T + Send + Sync + Clone,
T: Send,
F: Fn(&mut T, Self::Item) -> Result<(), E> + Send + Sync + Clone,
E: Send { ... }
fn reduce_with<F>(self, reduce_fn: F) -> Option<Self::Item>
where F: Fn(Self::Item, Self::Item) -> Self::Item + Send + Sync + Clone,
Self::Item: Sync + Clone { ... }
fn try_reduce<Identity, F, T, E>(
self,
identity: Identity,
reduce_fn: F,
) -> Result<T, E>
where Self::Item: Into<Result<T, E>>,
Identity: Fn() -> T + Send + Sync + Clone,
F: Fn(T, T) -> Result<T, E> + Send + Sync + Clone,
T: Send,
E: Send { ... }
fn try_reduce_with<F>(self, reduce_fn: F) -> Option<Self::Item>
where Self::Item: TryStreamItem,
F: Fn(<Self::Item as TryStreamItem>::Output, <Self::Item as TryStreamItem>::Output) -> Self::Item + Send + Sync + Clone { ... }
fn sum<S>(self) -> S
where S: Sum<Self::Item> + Send { ... }
fn sum_reassociated<S>(self) -> S
where S: Sum<Self::Item> + Sum + Send { ... }
fn product<P>(self) -> P
where P: Product<Self::Item> + Send { ... }
fn product_reassociated<P>(self) -> P
where P: Product<Self::Item> + Product + Send { ... }
fn min(self) -> Option<Self::Item>
where Self::Item: Ord { ... }
fn max(self) -> Option<Self::Item>
where Self::Item: Ord { ... }
fn min_by<F>(self, compare: F) -> Option<Self::Item>
where F: Fn(&Self::Item, &Self::Item) -> Ordering + Send + Sync + Clone { ... }
fn max_by<F>(self, compare: F) -> Option<Self::Item>
where F: Fn(&Self::Item, &Self::Item) -> Ordering + Send + Sync + Clone { ... }
fn min_by_key<K, F>(self, key_fn: F) -> Option<Self::Item>
where K: Ord,
F: Fn(&Self::Item) -> K + Send + Sync + Clone { ... }
fn max_by_key<K, F>(self, key_fn: F) -> Option<Self::Item>
where K: Ord,
F: Fn(&Self::Item) -> K + Send + Sync + Clone { ... }
fn find_any<F>(self, predicate: F) -> Option<Self::Item>
where F: Fn(&Self::Item) -> bool + Send + Sync + Clone,
Self::Item: Sync { ... }
}Expand description
Core parallel iterator trait for Moirai’s Rayon-style non-indexed subset.
Required Associated Types§
Required Methods§
Sourcefn drive<C, R>(self, consumer: C) -> R
fn drive<C, R>(self, consumer: C) -> R
Drive the Consumer protocol over this iterator’s items.
§Concurrency contract
Large owned and borrowed vector sources split their consumer recursively
and run one branch through Moirai’s nesting-safe SyncTask scope. Small
shards remain inline so scheduler overhead does not dominate the work.
Scope admission refusal runs the branch on the caller, preserving the
every-item contract under shutdown or bounded-queue pressure. The
resulting consumer combination preserves logical source order. The
infallible iterator contract recovers an unclaimed branch on the caller
if the scheduler cannot admit the scoped job; bounded admission refusal
is handled by the scheduler’s caller-lane fallback before this method
returns. A scheduler shutdown therefore degrades this drive to ordered
caller-side execution rather than dropping work.
Provided Methods§
Sourcefn seq_iter(self) -> impl Iterator<Item = Self::Item>
fn seq_iter(self) -> impl Iterator<Item = Self::Item>
Convert the logical item stream into a sequential iterator.
The default preserves compatibility for existing implementations by
materializing through seq_items. Sources and
adapters that can expose their logical stream directly override this
method, allowing sequential terminals to retain one standard iterator
invocation without allocating an intermediate vector.
§Examples
use moirai_iter::parallel::{IntoParallelIterator, ParallelIterator};
let items = vec![1_u32, 2, 3]
.into_par_iter()
.seq_iter()
.collect::<Vec<_>>();
assert_eq!(items, vec![1, 2, 3]);Sourcefn seq_try_fold<T, B, F>(self, init: T, fold_fn: F) -> ControlFlow<B, T>
fn seq_try_fold<T, B, F>(self, init: T, fold_fn: F) -> ControlFlow<B, T>
Fold this iterator’s logical item stream left to right, stopping at the
first ControlFlow::Break.
This is the folding counterpart to seq_iter and the
base every folding Consumer runs on: a shard’s items reach the
accumulator one at a time. The default delegates to seq_iter, whose
compatibility implementation materializes through
seq_items; sources and adapters on the terminal hot
path override seq_iter to stream without an intermediate Vec.
The break value is the accumulator as it stood when the fold stopped, so
a caller that needs the partial result on early exit reads it from the
Break arm.
Sourcefn seq_fold<T, F>(self, init: T, fold_fn: F) -> T
fn seq_fold<T, F>(self, init: T, fold_fn: F) -> T
Fold this iterator’s logical item stream left to right.
The non-short-circuiting form of seq_try_fold;
it inherits that method’s streaming behaviour, so overriding either
seq_iter or seq_try_fold is enough to make both allocation-free.
Sourcefn seq_items_window(self, skip: usize, take: Option<usize>) -> Vec<Self::Item>
fn seq_items_window(self, skip: usize, take: Option<usize>) -> Vec<Self::Item>
Collect a logical window from the sequential item stream.
Sourcefn seq_items_reversed(self) -> Vec<Self::Item>
fn seq_items_reversed(self) -> Vec<Self::Item>
Collect items in reverse logical order.
Sourcefn seq_items_reversed_prefix(self, count: usize) -> Vec<Self::Item>
fn seq_items_reversed_prefix(self, count: usize) -> Vec<Self::Item>
Collect a prefix from the reversed logical item stream.
Sourcefn map<F, R>(self, map_fn: F) -> Map<Self, F>
fn map<F, R>(self, map_fn: F) -> Map<Self, F>
Map operation that transforms each element in parallel.
Sourcefn map_with<T, F, R>(self, init: T, map_fn: F) -> MapWith<Self, T, F>
fn map_with<T, F, R>(self, init: T, map_fn: F) -> MapWith<Self, T, F>
Map operation with cloned per-operation state.
Sourcefn map_init<Init, T, F, R>(
self,
init: Init,
map_fn: F,
) -> MapInit<Self, Init, F>
fn map_init<Init, T, F, R>( self, init: Init, map_fn: F, ) -> MapInit<Self, Init, F>
Map operation with lazily initialized state.
Sourcefn update<F>(self, update_fn: F) -> Update<Self, F>
fn update<F>(self, update_fn: F) -> Update<Self, F>
Mutate each item by reference and yield the mutated item.
Sourcefn filter<F>(self, filter_fn: F) -> Filter<Self, F>
fn filter<F>(self, filter_fn: F) -> Filter<Self, F>
Filter operation that retains elements matching a predicate.
Sourcefn inspect<F>(self, inspect_fn: F) -> Inspect<Self, F>
fn inspect<F>(self, inspect_fn: F) -> Inspect<Self, F>
Inspect each element by shared reference without changing the stream.
Sourcefn panic_fuse(self) -> PanicFuse<Self>
fn panic_fuse(self) -> PanicFuse<Self>
Preserve value semantics while stopping sibling work after panic where applicable.
Sourcefn filter_map<F, R>(self, filter_map_fn: F) -> FilterMap<Self, F>
fn filter_map<F, R>(self, filter_map_fn: F) -> FilterMap<Self, F>
Map each element to an optional value and retain present values.
Sourcefn while_some<T>(self) -> WhileSome<Self>
fn while_some<T>(self) -> WhileSome<Self>
Unwrap a prefix of present values from an optional stream.
Sourcefn flat_map<F, U>(self, flat_map_fn: F) -> FlatMap<Self, F>where
F: Fn(Self::Item) -> U + Send + Sync + Clone,
U: IntoIterator,
<U as IntoIterator>::Item: Send + Sync + 'static,
fn flat_map<F, U>(self, flat_map_fn: F) -> FlatMap<Self, F>where
F: Fn(Self::Item) -> U + Send + Sync + Clone,
U: IntoIterator,
<U as IntoIterator>::Item: Send + Sync + 'static,
Map each element to an iterator and flatten the resulting sequence.
Sourcefn flat_map_iter<F, U>(self, flat_map_fn: F) -> FlatMap<Self, F>where
F: Fn(Self::Item) -> U + Send + Sync + Clone,
U: IntoIterator,
<U as IntoIterator>::Item: Send + Sync + 'static,
fn flat_map_iter<F, U>(self, flat_map_fn: F) -> FlatMap<Self, F>where
F: Fn(Self::Item) -> U + Send + Sync + Clone,
U: IntoIterator,
<U as IntoIterator>::Item: Send + Sync + 'static,
Map each element to a serial iterator and flatten the resulting sequence.
Sourcefn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Flatten nested item streams with standard left-to-right semantics.
Sourcefn flatten_iter(self) -> Flatten<Self>
fn flatten_iter(self) -> Flatten<Self>
Flatten nested serial iterators with standard left-to-right semantics.
Sourcefn enumerate(self) -> Enumerate<Self>
fn enumerate(self) -> Enumerate<Self>
Pair each element with its zero-based position in the logical sequence.
Sourcefn zip<J>(self, other: J) -> Zip<Self, J>where
J: ParallelIterator,
Self::Item: Sync + 'static,
<J as ParallelIterator>::Item: Sync + 'static,
fn zip<J>(self, other: J) -> Zip<Self, J>where
J: ParallelIterator,
Self::Item: Sync + 'static,
<J as ParallelIterator>::Item: Sync + 'static,
Pair elements with another parallel iterator, stopping at the shorter input.
Sourcefn zip_eq<J>(self, other: J) -> ZipEq<Self, J>where
J: ParallelIterator,
Self::Item: Sync + 'static,
<J as ParallelIterator>::Item: Sync + 'static,
fn zip_eq<J>(self, other: J) -> ZipEq<Self, J>where
J: ParallelIterator,
Self::Item: Sync + 'static,
<J as ParallelIterator>::Item: Sync + 'static,
Pair elements with another parallel iterator and require equal lengths.
Sourcefn take(self, count: usize) -> Take<Self>
fn take(self, count: usize) -> Take<Self>
Retain at most count elements from the logical sequence prefix.
Sourcefn take_any(self, count: usize) -> Take<Self>
fn take_any(self, count: usize) -> Take<Self>
Retain at most count items from this non-indexed deterministic stream.
Sourcefn skip(self, count: usize) -> Skip<Self>
fn skip(self, count: usize) -> Skip<Self>
Discard count elements from the logical sequence prefix.
Sourcefn skip_any(self, count: usize) -> Skip<Self>
fn skip_any(self, count: usize) -> Skip<Self>
Discard count items from this non-indexed deterministic stream.
Sourcefn take_any_while<F>(self, predicate: F) -> TakeAnyWhile<Self, F>
fn take_any_while<F>(self, predicate: F) -> TakeAnyWhile<Self, F>
Retain this deterministic stream prefix while predicate returns true.
Sourcefn skip_any_while<F>(self, predicate: F) -> SkipAnyWhile<Self, F>
fn skip_any_while<F>(self, predicate: F) -> SkipAnyWhile<Self, F>
Discard this deterministic stream prefix while predicate returns true.
Sourcefn chain<J>(self, other: J) -> Chain<Self, J>
fn chain<J>(self, other: J) -> Chain<Self, J>
Concatenate this iterator with another iterator of the same item type.
Sourcefn intersperse(self, separator: Self::Item) -> Intersperse<Self>
fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
Insert a cloned separator between adjacent logical items.
Sourcefn chunks(self, chunk_size: usize) -> Chunks<Self>
fn chunks(self, chunk_size: usize) -> Chunks<Self>
Group the logical item stream into non-empty chunks.
Sourcefn copied<'data, T>(self) -> Copied<Self>
fn copied<'data, T>(self) -> Copied<Self>
Copy referenced items out of a borrowed parallel stream.
Sourcefn cloned<'data, T>(self) -> Cloned<Self>
fn cloned<'data, T>(self) -> Cloned<Self>
Clone referenced items out of a borrowed parallel stream.
Sourcefn reduce<F>(self, reduce_fn: F) -> Option<Self::Item>
fn reduce<F>(self, reduce_fn: F) -> Option<Self::Item>
Reduce operation that combines all elements.
Sourcefn collect_vec_list(self) -> LinkedList<Vec<Self::Item>>
fn collect_vec_list(self) -> LinkedList<Vec<Self::Item>>
Collect into a list of owned vector segments.
This bounded terminal mirrors Rayon’s public collect_vec_list return
shape while preserving Moirai’s logical item stream as one moved
segment. Segment count is not part of the semantic contract; flattening
the returned list yields the same logical item sequence as collect.
Sourcefn partition<C, F>(self, predicate: F) -> (C, C)
fn partition<C, F>(self, predicate: F) -> (C, C)
Partition items into two collections while preserving relative order.
Sourcefn partition_map<A, B, P, L, R>(self, predicate: P) -> (A, B)
fn partition_map<A, B, P, L, R>(self, predicate: P) -> (A, B)
Split mapped Either values into two collections while preserving side-local order.
Sourcefn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
Split a stream of pairs into two collections while preserving order.
Sourcefn sequential(self) -> SequentialAdapter<Self>
fn sequential(self) -> SequentialAdapter<Self>
Convert to a sequential iterator.
Sourcefn find_first<F>(self, predicate: F) -> Option<Self::Item>
fn find_first<F>(self, predicate: F) -> Option<Self::Item>
Find the first element matching a predicate.
Every shard runs: a shard that has not started may hold an earlier match
than one already found, so this terminal cannot abandon shards the way
find_any does. Each shard still stops at its own
first match.
Sourcefn find_last<F>(self, predicate: F) -> Option<Self::Item>
fn find_last<F>(self, predicate: F) -> Option<Self::Item>
Find the last element matching a predicate in the logical stream.
Sourcefn position_first<F>(self, predicate: F) -> Option<usize>
fn position_first<F>(self, predicate: F) -> Option<usize>
Find the first logical index matching a predicate.
Sequential by contract: a logical index is a property of the whole
stream, and the non-indexed consumer protocol cannot hand a shard its
own base index. Consumer::split_at carries the source split point,
which a length-changing adapter such as filter invalidates before it
reaches the shard. The stream is folded rather than collected, so no
intermediate vector is built.
Sourcefn position_any<F>(self, predicate: F) -> Option<usize>
fn position_any<F>(self, predicate: F) -> Option<usize>
Find any logical index matching a predicate.
Sourcefn position_last<F>(self, predicate: F) -> Option<usize>
fn position_last<F>(self, predicate: F) -> Option<usize>
Find the last logical index matching a predicate.
Sequential for the reason given on
position_first, and folded rather than
collected.
Sourcefn positions<F>(self, predicate: F) -> Positions<Self, F>
fn positions<F>(self, predicate: F) -> Positions<Self, F>
Return all logical indices whose items match a predicate.
Sourcefn find_map_first<F, R>(self, map_fn: F) -> Option<R>
fn find_map_first<F, R>(self, map_fn: F) -> Option<R>
Find and map the first matching element in the logical stream.
Sourcefn find_map_any<F, R>(self, map_fn: F) -> Option<R>
fn find_map_any<F, R>(self, map_fn: F) -> Option<R>
Find and map any matching element in the logical stream.
Shards that have not started are abandoned once any shard produces a
mapped value, so the result is a mapped match rather than necessarily
the logically first one. Use
find_map_first when order matters.
Sourcefn find_map_last<F, R>(self, map_fn: F) -> Option<R>
fn find_map_last<F, R>(self, map_fn: F) -> Option<R>
Find and map the last matching element in the logical stream.
Sourcefn for_each_with<T, F>(self, init: T, op: F)
fn for_each_with<T, F>(self, init: T, op: F)
Apply a function to each element with cloned per-operation state.
Sequential by contract: one state value threads through the whole
stream, so op observes every prior item’s effect. A parallel form
would have to give each shard its own clone, which is a different
contract. The stream is folded rather than collected.
Sourcefn for_each_init<Init, T, F>(self, init: Init, op: F)
fn for_each_init<Init, T, F>(self, init: Init, op: F)
Apply a function to each element with lazily initialized state.
Sequential for the reason given on
for_each_with.
Sourcefn try_for_each<F, E>(self, op: F) -> Result<(), E>
fn try_for_each<F, E>(self, op: F) -> Result<(), E>
Apply a fallible function to each element and stop on the first error.
The returned error is the first one in logical order. Each shard stops at its own first error, but no shard is abandoned: an earlier shard may still hold an earlier error than one already reported.
Sourcefn try_for_each_with<T, F, E>(self, init: T, op: F) -> Result<(), E>
fn try_for_each_with<T, F, E>(self, init: T, op: F) -> Result<(), E>
Apply a fallible function to each element with cloned per-operation state.
Sequential for the reason given on
for_each_with.
Sourcefn try_for_each_init<Init, T, F, E>(self, init: Init, op: F) -> Result<(), E>
fn try_for_each_init<Init, T, F, E>(self, init: Init, op: F) -> Result<(), E>
Apply a fallible function to each element with lazily initialized state.
Sequential for the reason given on
for_each_with.
Sourcefn reduce_with<F>(self, reduce_fn: F) -> Option<Self::Item>
fn reduce_with<F>(self, reduce_fn: F) -> Option<Self::Item>
Reduce with an associative operation.
Sourcefn try_reduce<Identity, F, T, E>(
self,
identity: Identity,
reduce_fn: F,
) -> Result<T, E>
fn try_reduce<Identity, F, T, E>( self, identity: Identity, reduce_fn: F, ) -> Result<T, E>
Reduce a fallible item stream with an identity and associative operation.
Sourcefn try_reduce_with<F>(self, reduce_fn: F) -> Option<Self::Item>where
Self::Item: TryStreamItem,
F: Fn(<Self::Item as TryStreamItem>::Output, <Self::Item as TryStreamItem>::Output) -> Self::Item + Send + Sync + Clone,
fn try_reduce_with<F>(self, reduce_fn: F) -> Option<Self::Item>where
Self::Item: TryStreamItem,
F: Fn(<Self::Item as TryStreamItem>::Output, <Self::Item as TryStreamItem>::Output) -> Self::Item + Send + Sync + Clone,
Reduce a fallible item stream without an identity value.
Sourcefn sum<S>(self) -> S
fn sum<S>(self) -> S
Sum the complete logical stream through one standard Iterator::sum
invocation.
std::iter::Sum does not expose an operation for combining partial
output values. This method therefore preserves every lawful
Sum<Self::Item> implementation through the iterator returned by
seq_iter. Compatible sources and adapters stream
directly; other implementations retain the default materialized path.
Use sum_reassociated only when the output’s
partial values may be reassociated.
Sourcefn sum_reassociated<S>(self) -> S
fn sum_reassociated<S>(self) -> S
Sum independently produced item fragments and merge their outputs.
This terminal invokes Sum<Self::Item> on empty and one-item streams,
then invokes Sum<S> on pairs of partial outputs. That stronger
contract enables parallel shard folding without materializing the full
logical stream, but it is not equivalent to sum for an
arbitrary Sum implementation.
§Ordering
Partial outputs are merged in logical shard order. The merge tree is a function of the input length alone, so arithmetic results are reproducible across runs and worker counts. Floating-point results need not be bit-identical to a strictly left-to-right sum.
Sourcefn product<P>(self) -> P
fn product<P>(self) -> P
Multiply the complete logical stream through one standard
Iterator::product invocation.
This preserves every lawful Product<Self::Item> implementation through
seq_iter. Compatible sources and adapters stream
directly; other implementations retain the default materialized path.
Use product_reassociated only when
partial output values may be reassociated.
Sourcefn product_reassociated<P>(self) -> P
fn product_reassociated<P>(self) -> P
Multiply independently produced item fragments and merge their outputs.
This terminal invokes Product<Self::Item> on empty and one-item
streams, then invokes Product<P> on pairs of partial outputs. See
sum_reassociated for the deterministic merge
ordering and semantic distinction from the standard terminal.
Sourcefn min_by<F>(self, compare: F) -> Option<Self::Item>
fn min_by<F>(self, compare: F) -> Option<Self::Item>
Return the minimum item according to a comparator.
Ties resolve to the earliest item in logical order, matching
Iterator::min_by. Shards keep their own earliest minimum and merges
keep the earlier shard’s on equality, so the tie-break is the same at
every level of the merge tree.
Sourcefn max_by<F>(self, compare: F) -> Option<Self::Item>
fn max_by<F>(self, compare: F) -> Option<Self::Item>
Return the maximum item according to a comparator.
Ties resolve to the latest item in logical order, matching
Iterator::max_by.
Sourcefn min_by_key<K, F>(self, key_fn: F) -> Option<Self::Item>
fn min_by_key<K, F>(self, key_fn: F) -> Option<Self::Item>
Return the minimum item according to an ordered key.
Expressed through min_by, so tie-breaking matches
Iterator::min_by_key. key_fn runs twice per comparison rather than
being cached alongside the item, which keeps the key out of the value
that crosses shard boundaries and so avoids a K: Send requirement.
Sourcefn max_by_key<K, F>(self, key_fn: F) -> Option<Self::Item>
fn max_by_key<K, F>(self, key_fn: F) -> Option<Self::Item>
Return the maximum item according to an ordered key.
Expressed through max_by; see
min_by_key for the key-evaluation note.
Sourcefn find_any<F>(self, predicate: F) -> Option<Self::Item>
fn find_any<F>(self, predicate: F) -> Option<Self::Item>
Find any element matching a predicate.
Shards that have not started are abandoned once any shard finds a match,
so the returned item is a match rather than necessarily the logically
first one. Use find_first when order matters.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".