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

A RandomAccessIterator`RandomAccessIteratorshould be either infinite or a` should be either infinite or a DoubleEndedIterator`DoubleEndedIterator. Calling`. Calling next()`next()or` or next_back()`next_back()on a` on a RandomAccessIterator`RandomAccessIteratorreduces the indexable range accordingly. That is,` reduces the indexable range accordingly. That is, it.idx(1)`it.idx(1)will become` will become it.idx(0)`it.idx(0)after` after it.next()`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`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`None` if the index is out of bounds

Implementors