Try   HackMD

Eric/Vincenzo

2024-08-29

fmease's metavar test.

// crate a
//@ edition: 2018
#![macro_metavar_expr]

macro_rules! make_matcher {
    ($name:ident, $fragment_type:ident) => {
        macro_rules! $name {
            ($$_:$fragment_type) => { true },
            ($_:tt) => { false }, 
        }
    }
}

// crate b
//@ edition: 2024
use a::make_matcher;

// defines a macro `is_expr` that tells you whether its argument is an expression
make_matcher!(is_expr, expr);

let x = is_expr(const { 0 });
// what is x?
//
// what if we put the make_matcher!(is_expr,...) line in crate a?