Allow iterating backwards
- Dominant language
- Rust
- Stars
- 167
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
It would be very convenient if this library supported backwards iteration of the range. Here's my use case: I have a trait called `Undo` that represents an action that can be undone. I would like to implement this trait for tuples, to allow a sequence of actions to be undone. The problem is that the tuples ought to be undone in reverse, starting from the end of the tuple.
I'd love to write something like
```rust
seq!(N in 2..=4 {
#(
seq!(I in 0..N {
impl Undo for (#( U~I, )*)
where
#(U~I: Undo,)*
{
type Target = T;
fn revert(self, target: &mut Self::Target) {
seq!(J in (0..N).rev() {
self.J.revert(target);
});
}
}
});
)*
});
```
Or alternately, if there were a way I could handle the reverse indexing myself like
```rust
seq!(N in 2..=4 {
#(
seq!(I in 0..N {
impl Undo for (#( U~I, )*)
where
#( U~I: Undo, )*
{
type Target = T;
fn revert(self, target: &mut Self::Target) {
#( self.#(N - I).revert(target); )*
})
}
});
)*
});
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.