Lyricdev
GitHub

interface Iterator

pub interface Iterator

A source of values, one at a time.

next() gives the next value, and null at the end, for good once given. A struct iterator changes as it goes, so next writes it. A walk that can fail, such as a file's lines, names its Error, and next() throws it; the loop over it is marked, for (line in try lines).

Associated types

type Item
type Error :: [Error] = never

What a walk may throw: nothing, unless a conformer says otherwise.

Methods

mut fn next(): ?Self.Item throws Self.Error
fn sizeHint(): (int, ?int)

Returns how many values are left: at least the first, at most the second where that is known.

A collector uses it to size its storage once.