Documentation

sliding_windows

This crate offers an Iterator adaptor, which yields "sliding windows" over the elements returned by the wrapped iterator.

It's worth to note that it does not copy elements, which makes the code relatively performant.

Links

Documentation

Example

extern crate sliding_windows;
use sliding_windows::{IterExt, SlidingWindowStorage};

let mut storage: SlidingWindowStorage<u32> = SlidingWindowStorage::new(3);

for x in (0..5).sliding_windows(&mut storage) {
    println!("{:?}", x);
}

// This outputs:
// [0, 1, 2]
// [1, 2, 3]
// [2, 3, 4]

In other languages