Trait std::iter::IteratorUnstable [-]  [+] [src]

pub trait Iterator<A> {
    fn next(&mut self) -> Option<A>;

    fn size_hint(&self) -> (uint, Option<uint>) { ... }
}

An interface for dealing with "external iterators". These types of iterators can be resumed at any time as all state is stored internally as opposed to being located on the call stack.

The Iterator protocol states that an iterator yields a (potentially-empty, potentially-infinite) sequence of values, and returns None to signal that it's finished. The Iterator protocol does not define behavior after None is returned. A concrete Iterator implementation may choose to behave however it wishes, either by returning None infinitely, or by doing something else.

Required Methods

fn next(&mut self) -> Option<A>

Advance the iterator and return the next value. Return None when the end is reached.

Provided Methods

fn size_hint(&self) -> (uint, Option<uint>)

Returns a lower and upper bound on the remaining length of the iterator.

An upper bound of None means either there is no known upper bound, or the upper bound does not fit within a uint.

Implementors