Questions about rust macro


#1

Hi,

I constructed the following macro and it could pass the compilation. But I’m wondering how to use this or whether it’s legal in syntax.

macro_rules! foo {
   (aa$e:expr) => { println!(stringify!($e)); }
}

#2

It is legal: https://play.rust-lang.org/?gist=65ea05f98a94e7cf3cf708d740ce4d58

fn main() {
    foo!(aa 1 + 1);
}

#3

oh, thx a lot