I am trying to create a macro to perform a certain action for every element in a tuple in order to compensate for not being able to iterate over them.
I wrote some code that replicates my issue:
fn main() {
let tuple = (1, 2);
macro_rules! index_tuple {
($($i:literal),+) => {
$(
let t$i = tuple.$i;
)+
}
}
index_tuple!(0, 1);
}
But I have been met with the following error:
error: expected one of `:`, `;`, `=`, `@`, or `|`, found `0`
I have tried expanding the macro with CLion and the expanded macro worked perfectly fine so I am uncertain whether it is my fault or not.