4 type Item<'a> where Self: 'a;
6 fn next<'a>(&'a mut self) -> Option<Self::Item<'a>>;
8 fn for_each<F>(mut self, mut f: F)
9 where Self: Sized, F: for<'a> FnMut(Self::Item<'a>)
11 while let Some(item) = self.next() {
17 pub struct Windows<T> {
24 pub fn new(items: Vec<T>, len: usize) -> Self {
25 Self { items, start: 0, len }
29 impl<T> Iter for Windows<T> {
30 type Item<'a> = &'a mut [T] where T: 'a;
32 fn next<'a>(&'a mut self) -> Option<Self::Item<'a>> {
33 let slice = self.items.get_mut(self.start..self.start + self.len)?;
40 Windows::new(vec![1, 2, 3, 4, 5], 3)
41 .for_each(|slice| println!("{:?}", slice));