Implementation of DoubleEndedIteratortrait on the Iter type for Arena, including two additional unit tests iter_rev() and iter_both_directions() in iter/iter.rs to confirm expected behavior.
I'm using thunderdome in another project, and I found myself needing to do arena.iter().collect::<Vec<_>>().into_par_iter().rev(), which is disgusting and not optimal. I looked into the iterator for Arena and saw that it was using a slice::Iter internally, which implements DoubleEndedIterator, so I made some additions and wrote some tests to confirm it works.
I hope the code aligns with your methodology. Given that arena.iter() doesn't define an explicit order, I see no reason why "backwards iteration" would yield undesirable outcomes. I am unsure if the check for self.slot > self.len on next() and next_back() is strictly necessary, but it felt appropriate to include.
Implementation of
DoubleEndedIterator
trait on theIter
type forArena
, including two additional unit testsiter_rev()
anditer_both_directions()
initer/iter.rs
to confirm expected behavior.I'm using
thunderdome
in another project, and I found myself needing to doarena.iter().collect::<Vec<_>>().into_par_iter().rev()
, which is disgusting and not optimal. I looked into the iterator forArena
and saw that it was using aslice::Iter
internally, which implementsDoubleEndedIterator
, so I made some additions and wrote some tests to confirm it works.I hope the code aligns with your methodology. Given that
arena.iter()
doesn't define an explicit order, I see no reason why "backwards iteration" would yield undesirable outcomes. I am unsure if the check forself.slot > self.len
onnext()
andnext_back()
is strictly necessary, but it felt appropriate to include.