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

pub trait Iterator where <Self as Iterator>::Item: Sized {
    type Item;

    fn next(&mut self) -> Option<<Self as Iterator>::Item>;

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

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.

Associated Types

type Item

Required Methods

fn next(&mut self) -> Option<<Self as Iterator>::Item>

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

Provided Methods

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

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 usize.