TypedIterator
Names an exact cursor item type without external associated-type projection.
Module std.iteration
import std.iteration;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
TypedIterator
pub concept TypedIterator<Self, T>Names an exact cursor item type without external associated-type projection.
Satisfaction is structural and introduces no runtime witness. A Next result may own a value or borrow an exact readonly/writable reference; neither the concept nor its adapters extend backing storage lifetime. Implementations document thread affinity and invalidation; concurrent mutation needs their own synchronization contract. Self: Concrete mutable traversal state. T: Exact item type, including its reference access when applicable.
Example
module example.typed_iterator;
from std.iteration import Take, Skip, Count;
fn Main() -> i32 {
let Range = 0_i32..5_i32;
var Tail = Skip<i32>(Range.CreateIterator(), 2);
var Prefix = Take<i32>(move(Tail), 2);
var Total: i32 = 0;
while Prefix.Next() is .Some { Value = Item } { Total += Item; }
if Total != 5 { return 1; }
if Count(Range.CreateIterator()) != 5 { return 2; }
return 0;
}TypedIterator.Next
requires fn Next() -> T?;Advances the cursor and returns its exact value/reference item. Return: One optional item; owning payloads require ordinary deterministic cleanup.