Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jpmckinney opened this issue Feb 17, 2023 · 1 comment

Comments

@jpmckinney
Copy link

jpmckinney commented Feb 17, 2023

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)] ?

@Veykril
Copy link
Owner

Veykril commented Feb 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants