I'm working on a project that uses some complex declarative macros. I ran into an issue, which I have dumbed down in the following simple code snippet. I can't understand why I cannot form the set of arguments to pass to a function with a macro.
What am I missing? Thank you all in advance!
macro_rules! replace {
() => {a, b};
}
fn add_num (a: u32, b: u32) -> u32 {
a+b
}
fn main() {
let a : u32 = 2;
let b : u32 = 4;
println!("{}", add_num(replace!()));
}
This answer has exactly what I was looking for:
Calling functions with different numbers of arguments in Rust macros
My code snippet was an over simplification which actually lead me to a different problem. The original issue I had was solved similarly to the answer in the link: by building the argument list and keep passing the function name until the last match, which is where the function is called with the final argument list.
Thank you all!