pub trait Pairwisor: Iterator {
    // Provided method
    fn pairwise(self) -> Pairwise<Self> 
       where Self::Item: Copy,
             Self: Sized + Iterator { ... }
}
Expand description

An iterator that returns pair values of the preceding iterator.

Pairwise is created by the pairwise method on Iterator. See its documentation for more.

Provided Methods§

source

fn pairwise(self) -> Pairwise<Self> where Self::Item: Copy, Self: Sized + Iterator,

An iterator adaptor that yields the preceding iterator in pairs.

Similar to the windows method on slices, but with owned elements.

The first element of the preceding iterator is yielded unchanged.

Examples

Basic usage:

use rs3cache::utils::adapters::Pairwisor;

let mut iter = (0..6).pairwise();

assert_eq!(iter.next(), Some((0, 1)));
assert_eq!(iter.next(), Some((1, 2)));
assert_eq!(iter.next(), Some((2, 3)));
assert_eq!(iter.next(), Some((3, 4)));
assert_eq!(iter.next(), Some((4, 5)));
assert_eq!(iter.next(), None);

Implementors§