I'm trying to match the trait bounds for generic types:
macro_rules! test {
(
where $(
$bounded_type:ident: $( $bound:tt )++,
)+
) => {
// Dummy expansion for test:
struct Foo<T, U>
where $(
$bounded_type : $( $bound )++,
)+
{
t: T,
u: U
}
}
}
test! {
where
T: PartialEq + Clone,
U: PartialEq,
}
fn main() {}
Unfortunately, if I understand well, the only way to match a trait is a tt
fragment, but this fragment can match almost anything, so whatever I do, I get an error:
error: local ambiguity: multiple parsing options: built-in NTs tt ('bound') or 1 other option.
How can I match this piece of code?
Note that I do not need something very elegant (I do not need it for plublic users) but of course, the more elegant, the better.