pub struct IteratorState {
pub source: IteratorSource,
pub transforms: Vec<IteratorTransform>,
pub cursor: usize,
}Expand description
Lazy iterator carrier. Stored on the heap as
Arc<IteratorState>; the runtime slot label is
NativeKind::Ptr(HeapKind::Iterator).
cursor is preserved across clones (a cloned iterator continues from
the parent’s position); transforms append new stages without consuming
the source. Terminal operations (collect, forEach, reduce, etc.)
walk the (source, transforms, cursor) triple and emit results, leaving
the input state immutable so that let it = arr.iter().map(f); it.collect()
is observably the same as arr.iter().map(f).collect().
Fields§
§source: IteratorSource§transforms: Vec<IteratorTransform>§cursor: usizeImplementations§
Source§impl IteratorState
impl IteratorState
Sourcepub fn new(source: IteratorSource) -> Self
pub fn new(source: IteratorSource) -> Self
Construct a fresh iterator over source with no transforms.
Sourcepub fn with_transform(&self, t: IteratorTransform) -> Self
pub fn with_transform(&self, t: IteratorTransform) -> Self
Append a transform stage, returning a new IteratorState. The
receiver’s source and existing transforms are cloned (each is a
typed-Arc bump — no deep copy of the underlying buffers).
Trait Implementations§
Source§impl Clone for IteratorState
impl Clone for IteratorState
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
Per-field clone — IteratorSource and IteratorTransform are
already Clone (they hold typed Arc<T> payloads whose Clone
is a single atomic refcount bump).
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more