Types passed directly to macros pattern match the way you would expect, but if they're passed through another macro as ty, they stop matching:
macro_rules! mrtype {
( bool ) => ("b");
( i32 ) => ("i");
( f64 ) => ("f");
( &str ) => ("z");
( $_t:ty ) => ("o");
}
macro_rules! around {
( $t:ty ) => (mrtype!($t));
}
fn main() {
println!("{}{}{}", mrtype!(i32), around!(i32), around!(&str));
}
This prints ioo instead of iiz.
Passing tts instead of tys works, but if you have &str you need 2 tts, making everything unnecessarily complicated.