what are my options when I want to iterate in a non-consecutive fashion? e.g. I have
&[1,2,3,4,5,6,7,8,9,10,11,12] and want an iterator that yields
1,2,3, 7,8,9, 5,6,7, 10,11,12.
The reordering I'd like to achieve is not completely arbitrary, but limited to shuffling equally sized chunks around. However that doesn't seem to help much, since a chunks-iterator still yields items in the original order.
The tricky part: I'd like to avoid heap allocations (putting the iterators in a
Vec and shuffling them around there or so) for
no_std and performance reasons.
I want to be generic over array size and chunk size, both are known at compile time.
Some background to illustrate: the concrete problem I'm trying to solve is pixel reordering for several adjacent LED matrix displays.
since the displays are daisy chained there is a discrepancy between visual & backing store pixel order:
visualy, one wants to just store, process & show rows of pixels:
|1 2 3| |4 5 6| |7 8 9| |a b c| |d e f| |g h i| M1 M2 M3
however, if sent to the chain of displays in that order, things would get garbled because of the the connection topology (first, all pixels of M1, then all of M2, then M3):
|1 2 3| /|7 8 9| /|d e f| |4 5 6|/ |a b c|/ |g h i| M1 M2 M3