I have the following macro:
macro_rules! foo {
($a:ident) => { println!("Hello"); };
}
and calling it like so works:
foo!(int)
and prints "Hello", but when I change it to be either
macro_rules! foo {
($($a:ident)+) => { println!("Hello"); };
}
or
macro_rules! foo {
($($a:ident),+) => { println!("Hello"); };
}
and run it with
foo!(int int)
//or
foo!(int, int,)
I get an error:
| foo!(int, int,)
| ^^^ no rules expected this token in macro call
Why doesn't this work?
Note that the entire file I'm using is this:
// src/main.rs
pub fn main() {
foo!(int, int,)
}
By the way I'm using int
in this case just because it is what I had created an error message for, I'm writing a macro to turn a C# type to its equivalent rust type. Specifically for things like this:
type ffi_fn = ffi!(csharp public static void run_abc(string name));
//ffi_fn = `extern fn(*const u8) -> ()