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

Add support for Meta-Variable Expressions #11712

Closed
c410-f3r opened this issue Mar 15, 2022 · 3 comments
Closed

Add support for Meta-Variable Expressions #11712

c410-f3r opened this issue Mar 15, 2022 · 3 comments
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now

Comments

@c410-f3r
Copy link
Contributor

For more information, see rust-lang/rust#83527.

#![feature(macro_metavar_expr)]

macro_rules! mac {
    ( $($foo:ident)* ) => {
        0 + ${count(foo)}
    };
}

fn main() {
    let n = mac!(a b c);
    assert_eq!(n, 3);
}

Capture d’écran de 2022-03-15 09-58-47

@Veykril Veykril added A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now labels Mar 15, 2022
@c410-f3r
Copy link
Contributor Author

I guess at least dollar-dollar will be easy to implement

macro_rules! foo {
    () => {
        macro_rules! bar {
            ( $$( $$any:tt )* ) => { $$( $$any )* };
        }
    };
}

fn main() { foo!(); }

@c410-f3r
Copy link
Contributor Author

Closing in favor of #11952

@Veykril
Copy link
Member

Veykril commented Apr 15, 2022

Ah, I completely forgot about this issue already existing sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

2 participants