Crate iter_seq

Crate iter_seq 

Source
Expand description

Stateless, transformable, abstract sequences of values.

This crate provides a mechanism for working with abstract stateless sequences of arbitrary values. In contrast, standard iterators are stateful—that is, their state can be changed by calling next.

One significant limitation of the stateful model is its inability to encode compile-time invariants, which can lead to unnecessary overhead that the compiler often cannot reliably optimize away. This crate provides a “wrapper” around standard iterators that must be irreversibly converted into an iterator before its elements can be consumed.

§Example



use iter_seq::{Sequence, seq};

let odd_squares = seq::from_fn(|i| 2 * i as u32 + 1).map(|i| i * i);

let arr: [u32; 128] = odd_squares.take_exact_s::<128>()
    .collect_array();

for (i, n) in arr.iter().enumerate() {
    let j = 2 * i as u32 + 1;
    assert_eq!(j * j, *n);
}

Modules§

adapters
markers
seq

Macros§

collect_array
Collects a sequence into an array in the most efficient way possible, ensuring that no unnecessary memory copies will occur.

Structs§

ConstSize
DynamicSize
InfiniteSize

Enums§

SizeKind

Traits§

InfiniteSequence
A sequence that is guaranteed to produce elements indefinitely, unless a panic occurs.
IsDynamic
IsEqual
IsFinite
IsGreaterOrEqual
IsGreaterThan
IsInfinite
IsLessOrEqual
IsLessThan
Sequence
Represents a stateless abstract sequence of values.
Size
ToSize
ToUInt

Type Aliases§

U