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, repeat};
let odd_squares = repeat(())
.enumerate()
.map(|(i, _)| i as u32)
.map(|n| (n + 1) * (n + 1));
let arr: [u32; 128] = odd_squares.take_exact_s::<128>()
.collect_array();
for (i, n) in arr.iter().enumerate() {
assert_eq!((i as u32 + 1) * (i as u32 + 1), *n);
}
Re-exports§
pub use typenum;
Macros§
- collect_
array - Collects a sequence into an array in the most efficient way possible, ensuring that no unnecessary memory copies will occur.
Structs§
- Array
MutSlice Seq - Array
Seq - Array
Slice Seq - Const
- Used to allow the usage of
Uin a generic context. - Dynamic
Size - Enumerate
- A sequence that yields the current iteration index for every element.
- Flatten
- Infinite
Size - IterSeq
- A sequence created from an iterator.
- Map
- A sequence that transforms every element of the original sequence using
f - Repeat
- Static
Size - Take
ExactS Tn
Enums§
Traits§
- Array
Ext - Into
Iterator Ext - IsDynamic
- IsEqual
- IsFinite
- IsGreater
OrEqual - IsGreater
Than - IsInfinite
- IsLess
OrEqual - IsLess
Than - Lower
Bound - A
Sequencethat is guaranteed to yield at leastNelements, but could yield more. - Sequence
- Represents a stateless abstract sequence of values.
- Size
- ToUInt
- Unsigned
- The marker trait for compile time unsigned integers.
- Upper
Bound - A
Sequencethat is guaranteed to yield at mostNelements, but could yield less. - With
Lower Bound - With
Upper Bound