Macro core_extensions::parenthesize_args
source · macro_rules! parenthesize_args { ( $(:: $(@$leading:tt@)? )? $first:ident $(:: $trailing:ident)* ! { $($prefix:tt)* } $($extra:tt)* ) => { ... }; }
Expand description
Adaptor macro which passes arguments to a callback macro, wrapping them in parentheses.
§Example
use core_extensions::{count_tts, parenthesize_args};
fn main() {
assert_eq!(foo(), 5);
}
macro_rules! the_macro {
($func:ident $count:literal) => {
pub fn $func() -> u32 { $count }
}
}
// `parenthesize_args` invokes `count_tts` here,
// then `count_tts` counts `a b c d e` as having 5 tokens,
// passing `5` as the `$count` parameter to `the_macro`.
parenthesize_args!{
count_tts!{
the_macro!{foo}
}
a b c d e
}