Iterator cursors

Iterator<T> is a fused, single-pass cursor. next() advances it and returns Optional<T>. Copying the iterator aliases that cursor; calling iter() again on a collection creates an independent one.

Adapters such as map, filter, and take stay lazy. Terminal methods consume from the current position.

fn main() {
  let source = [1, 2, 3]
  let first = source.iter()
  let alias = first
  let second = source.iter()
  println(first.next())
  println(alias.next())
  println(second.next())
}
Output & diagnostics
Expected:
some(1)
some(2)
some(1)
Ctrl/⌘+Enter runs the current lesson.