For implementing a great declarative macro, it need tt to match a TraitName. For example, the following my_great_macro! have to call set_value! marcro:
macro_rules! my_great_macro {
......
set_value!(name, $t);//$t is a tt!
......
}
macro_rules! set_u32_value {
($name:expr, u32) => { //it's good to match when tt==u32
...
};
($name:expr, bool) => { //it's good to match when tt==bool
...
};
($name:expr, TraitName) => { //however, it cannot match TraitName!
...
};
($name:expr, StructName) => { //even StructName, it's good to match when tt==StructName
...
};
($($else:tt)*) => {};
}
It is good to match the tt pattern for u32, bool, and even StructName. But, it cannot match the pattern for any struct which impl TraitName.
Is it possible to implement this feature for a future version of rust language?