tlborm icon indicating copy to clipboard operation
tlborm copied to clipboard

macro_metavar_expr mentioned on page prior to saying there's "no direct way to do this"

Open jpmckinney opened this issue 3 years ago • 1 comments

I'm just reading through the book, and saw:

${count(ident)}: The number of times $ident repeats in the inner-most repetition in total.

on https://veykril.github.io/tlborm/decl-macros/macros-methodical.html

Then I go to the next page and it says:

Somehow turning inits into a literal 2 is a little trickier. It turns out that there's no direct way to do this, but we can do it by using a second macro_rules! macro.

Am I misunderstanding, or is there in fact a direct way if I use #![feature(macro_metavar_expr)] ?

jpmckinney avatar Feb 17 '23 19:02 jpmckinney

Yes metavar expressions will make counting very easy, but as they aren't stable yet, one has to stick to the more cumbersome counting tricks for non nightly toolchains.

Veykril avatar Feb 17 '23 21:02 Veykril