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
seq!(N in 2..=4 {
#(
seq!(I in 0..N {
impl<T, #( U~I, )*> Undo for (#( U~I, )*)
where
#(U~I: Undo<Target = T>,)*
{
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
seq!(N in 2..=4 {
#(
seq!(I in 0..N {
impl<T, #( U~I, )*> Undo for (#( U~I, )*)
where
#( U~I: Undo<Target = T>, )*
{
type Target = T;
fn revert(self, target: &mut Self::Target) {
#( self.#(N - I).revert(target); )*
})
}
});
)*
});
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
Or alternately, if there were a way I could handle the reverse indexing myself like