ndarray
ndarray copied to clipboard
implement DoubleEndedIterator for 1d `LanesIter`
trafficstars
In a project I wanted to iterate over the rows and columns of a 2d array in reverse but while rows and columns exist, the resulting LanesIter does not implement DoubleEndedIterator as of yet. It is possible to use indexing via row with reversed indices but that is less ergonomic.
This PR fixes this at least for 1d LanesIter and now allows one to do:
let a = ArcArray::from_iter(0..8).reshape((4, 2));
for (row, check) in a.rows().into_iter().rev().zip(&[[6, 7], [4, 5], [2, 3], [0, 1]]) {
assert_equal(row, check);
}
The implementation just delegates to the underlying 1d Baseiter which implements DoubleEndedIterator.
The trait is not implemented for higher dimensions however, which would need some additional work.