With the increasing complexity of generics, would it make sense to add a :generics matcher for macro_rules!? It wasn't terribly difficult to work with until recently, when min const generics stabilized. Now I feel it's a bit tedious to get anything that is remotely correct.
Yes please, one of the macros I work on wants to support generics, but actually trying to implement it means me giving it half the time.
It's such a long and complex chain to simply parse it and emit it back, and I do wish there was an easy tutorial for it.
To clarify, is this the production <'a, ..., T, ..., const N: U, ...> or like one of the components thereof? Because you're still going to be slightly sad, since <> aren't treated as real delimiters in macros...
Everything inside of the angle brackets is what I envisioned it would match.
I would love to see this, trying to implement one myself was very challenging. The only example I could find is the matcher used by pin-project-lite, and it cannot handle multiple bounds, HRTBs, or const generics:
$( $generics:ident
$(: $generics_bound:path)*
$(: ?$generics_unsized_bound:path)*
$(: $generics_lifetime_bound:lifetime)*
$(= $generics_default:ty)?
),*
+ is not allowed after path fragments, so I am not sure if writing this is even possible? I asked on the community discord server and was advised to match square brackets and use a tt matcher instead, or write a simple proc-macro to handle the generics.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.