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

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

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

Return 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 as Iterator>::Item>

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

Implementors