I'm trying to create a macro which, given a list of expressions, will use each of them, with literal zero being treated one way (in fact, it should be expanded to noop) and all other expressions the other. Here's the simplified example:
macro_rules! test {
($($x:expr),+) => {$(
test!(@impl $x);
)+};
(@impl 0) => {};
(@impl $x:expr) => {
println!("{:?}", $x);
}
}
fn main() {
test!(@impl 0);
test!(0, (1, 2, 3));
}
However, in this case the second test!
invocation prints all both the number and the tuple, ignoring the second arm and going only for the third one. Am I doing it wrong? I can't use runtime check, since the types ate different.