Function rustml::sliding::byte_slider [] [src]

pub fn byte_slider<'a>(s: &'a [u8], winlen: usize) -> Option<ByteSlider<'a>>

Creates a sliding window iterator of fixed size over bytes.

Returns None if winlen is zero, otherwise a ByteSlider is returned that implements Iterator to iterate through the bytes.

use rustml::sliding::*;

let v = vec![1, 2, 3, 4, 5, 6];
assert_eq!(
    byte_slider(&v, 3).unwrap().collect::<Vec<&[u8]>>(),
    vec![
        &[1, 2, 3],
        &[2, 3, 4],
        &[3, 4, 5],
        &[4, 5, 6]
    ]
);