Trait std::iter::RandomAccessIterator [] [src]

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

: trait has not proven itself as a widely useful abstraction for iterators, and more time may be needed for iteration on the design

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

Deprecated since 1.2.0

: trait has not proven itself as a widely useful abstraction for iterators, and more time may be needed for iteration on the design

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>

Deprecated since 1.2.0

: trait has not proven itself as a widely useful abstraction for iterators, and more time may be needed for iteration on the design

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

Implementors