Using a simple recursive macro like the example below, its common to take the first argument, then glob the rest.
macro_rules! count_tts {
() => {0usize};
($_head:tt $($tail:tt)*) => {1usize + count_tts!($($tail)*)};
}
Is there a way to recursively take the last argument?
This makes it possible to:
- Handle the arguments in reverse.
- Take all the previous arguments into account (count them for example, see related question)
Something like ($($head:tt)* $tail:tt)
... but this doesn't work.