std-method

DoubleEndedIterator::next_back — pull from the end

Remove one item from the back of the remaining sequence. Use it when the source supports double-ended traversal and you need only the last available item. Expected stdout (not executed): Some(7) Some(6) Common mistake: Calling next_back on an arbitrary Iterator without a trait bound.

Formal Syntax & Structure

rust syntaxrust
fn next_back(&mut self) -> Option<Self::Item>

Working Example

Example Snippetrust
fn main() {    let mut values = 5..8;    println!("{:?} {:?}", values.next_back(), values.next_back());}
Rust Reference