TypedIterator
Overview
TypedIterator extends core Iterator with an element-type advertisement via
.of, analogous to typed Array.of.
Core Iterator / Iterable have no element-type API. Qwiratry uses this role
so adaptor operators can share one pull/sink surface and still tell text chunks
from (later) structured values without parallel read-rows methods.
.ofreturns a type object (Mu:U). DefaultMumeans unspecified / heterogeneous: consumers inspect each pulled value.Homogeneous producers SHOULD override
.of(File pull usesStr).Qwiratry::QueryIteratordoesTypedIterator(default.ofisMufor query matches).TypedIterator::Wrapperwraps an existingIteratorwith an.ofwhen the producer does not implementTypedIteratoritself.iterator-of($iter)returns.offor aTypedIterator, elseMu(plainIteratoris treated as untyped).
Design notes: docs/rakudoc/Developing/Qwiratry-TOP-Prerequisites.md ยง5.3.
Iterator that advertises a homogeneous (or unspecified) element type.
of()
method of(--> Mu:U)
Element type for this stream. Default Mu = untyped / per-element handling.
Concrete TypedIterator that delegates pulls to an inner Iterator.
Use when wrapping a foreign iterator; prefer a dedicated class that
does TypedIterator when you own the pull logic.
Return $iterator.of when it does TypedIterator; otherwise Mu.
True when $of is a type compatible with text-chunk streams (Str).
Mu is not text-homogeneous โ callers must inspect elements.