pub trait MapRotated {
type Item;
type Output<I>;
fn map_rotated<I>(self, start: usize, f: impl FnMut(Self::Item) -> I) -> Self::Output<I>;
}
impl<const N: usize, T> MapRotated for [T; N]
where
T: Copy,
{
type Item = T;
type Output<I> = [I; N];
fn map_rotated<I>(self, start: usize, mut f: impl FnMut(Self::Item) -> I) -> Self::Output<I> {
let mut index = 0;
[(); N].map(|_| {
let item = self[(index + start) % self.len()];
index += 1;
f(item)
})
}
}