Implementation of the macro meta-variable RFC
In an eventual merge, please test the feature as much as possible to build a solid foundation for a future stabilization.
#![feature(macro_metavar_expr)]
macro_rules! build_and_modify_tuple {
( ( $( $l:literal ),* ) ) => {{
let mut tuple = ( $( $l ),* );
$( ${ignore(l)} tuple.${index()} *= 2; )*
tuple
}};
}
macro_rules! count {
( $( $e:stmt ),* ) => {
${ count(e) }
};
}
fn main() {
assert_eq!(build_and_modify_tuple!((0u8, 2i32, 4u128)), (0u8, 4i32, 8u128));
assert_eq!(count!(let _a = 1i32, let _ = (), if true {}), 3);
}