Closed
Description
It would be really swell if you could somehow access the index or depth of the current repeat in a macro.
Say if we are repeating with $($x)
, then $#x
would yield the index of the current $x
in the sequence.
The $#
is really not important, could be anything else really.
For example:
#[macro_export]
macro_rules! letmany {
($($x:ident),+) => {
let $x = $#x;
};
}
fn main() {
letmany!(a, b, c);
}
Would expand to:
fn main() {
let a = 0;
let b = 1;
let c = 2;
}
Thoughts?
Metadata
Metadata
Assignees
Labels
No labels