protocol DoubleEndedIterator<Self, T> { ... }
Self: Iterator<Self, T>

Iterators that can be consumed from both ends.

Implementing a double-ended iterator

Iterators that can be iterated from both ends efficiently should implement this protocol. next_back is the method that is used to iterate in reverse order. The convention is that next and next_back "meet in the middle", so that each element is visited once regardless of the direction of iteration.

All types implementing DoubleEndedIterator should also mix in DoubleEndedIteratorExt, which provides relevant extension methods, notably rev, which reverses the direction of iteration.

Example

Required methods