Trait core::iter::RandomAccessIterator [] [src]

pub trait RandomAccessIterator: Iterator {
    fn indexable(&self) -> usize;
    fn idx(&mut self, index: usize) -> Option<Self::Item>;
}
Unstable

: not widely used, may be better decomposed into Index and ExactSizeIterator

An object implementing random access indexing by usize

A RandomAccessIterator should be either infinite or a DoubleEndedIterator. Calling next() or next_back() on a RandomAccessIterator reduces the indexable range accordingly. That is, it.idx(1) will become it.idx(0) after it.next() is called.

Required Methods

fn indexable(&self) -> usize

Unstable

: not widely used, may be better decomposed into Index and ExactSizeIterator

Returns the number of indexable elements. At most std::usize::MAX elements are indexable, even if the iterator represents a longer range.

fn idx(&mut self, index: usize) -> Option<Self::Item>

Unstable

: not widely used, may be better decomposed into Index and ExactSizeIterator

Returns an element at an index, or None if the index is out of bounds

Implementors