macro_rules! add_one {
($e:expr) => {
$e + 1
};
}
macro_rules! test_macro {
($e:expr) => {
stringify!(add_one!($e))
};
}
fn main(){
let f = test_macro!(2); // output: add_one!(2)
}
The output is add_one!(2)
, which is not the expected result(e.g. 2 + 1
). It seems that the invocation of the macro in stringify!(...)
does not work. So, I wonder, are all tokens in stringify
treated as common text even though they match the macro invocation?