Trait Peekablepub

Source
:trait(pub) Peekable item { (Iterator Self item) }
  .peek ( Self  Self (Option item) )
Description

Lookahead protocol for iterators that support inspecting the next element without consuming it. Every Peekable MUST also be an Iterator — the associated item type is shared with the iterator's item via the (Iterator Self | item) constraint.

Types with a natural one-slot lookahead (token streams, buffered readers, lookahead parsers) implement this trait directly. There is no auto-wrapper for "any Iterator"; callers that need lookahead over a plain Iterator MUST provide their own :impl.

Required Methods

.peek ( Self Self (Option item) )

Return the next element without consuming it. Successive .peek calls without an intervening .next MUST return the same value. The returned Self MAY be the same handle with an internally populated cache. ( Self -> Self (Option item) )