I can implement a macro taking a type like this:
trait Boundable<A> {
fn max_value() -> A;
}
impl Boundable<u8> for u8 {
fn max_value() -> u8 { u8::MAX }
}
When I turn the impl
into a macro, why do I need to surround the type itself with angle brackets, as in this?
macro_rules! impl_boundable {
($a:ty) => {
impl Boundable<$a> for $a {
fn max_value() -> $a { <$a>::MAX }
}
};
}
impl_boundable!(i8);
In particular, <$a>::MAX
. Without it, the compiler gives me error missing angle brackets in associated item path
. It puzzles me why the macro code needs to be different from the non-macro code.