pub fn circular_windows<T>(
size: usize,
it: impl ExactSizeIterator<Item = T> + Clone,
) -> impl Iterator<Item = impl Iterator<Item = T>>Expand description
A composite function to be used with the crate::Composed::composed method that takes
an additional single usize as a parameter and computes a window of that size for every element
of the iterator (circular, it takes elements from the beginning for later windows).
This is requires to write an additional closure when it is used, but this might change in the future when a functor trait might be written instead.
ยงExample
let size=3;
let x = [1, 2, 3, 4].into_iter()
.composed(|i| circular_windows(3, i))
.flatten()
.collect::<Vec<_>>();
assert_eq!(x, [1,2,3,2,3,4,3,4,1,4,1,2])