| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
|
||
| impl<'a, A, D> DoubleEndedIterator for LanesIter<'a, A, D> | ||
| where | ||
| D: Dimension, |
There was a problem hiding this comment.
I expected this to be limited to the case where D=Ix1. Just like how .iter()'s Iter works. I think it's better that way, then the Baseiter does not leak out (it's in the where clause, that's a leak of internals into public API.)
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed that, and also applied the same change to LanesIterMut - it and LanesIter must of course change together.
Sorry, something went wrong.
This is especially useful when one wants to iterate over rows or columns of a 2d array in reverse. Co-authored-by: Ulrik Sverdrup <bluss@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
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.