Ident and type for macro parameter


#1

Hi,

I wonder if it’s possible given a macro like this

macro_rules! test {
    ($test:ident) => {
        println!("{}", $value);
    }
}

To get both the value and type for $test or do I always have to send in the type of test as a separate input to the macro?

Cheers!


#2

Macros have no abilities beyond normal code for working out the type of something. If you can’t write it without macros, you can’t write it with macros.


#3

Yeah that is a good point. Thanks!