2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2022-04-17 10:00:10 -05:00
|
|
|
#![allow(unused_macro_rules)]
|
|
|
|
|
2017-05-15 04:26:26 -05:00
|
|
|
/// A compile-time map from identifiers to arbitrary (heterogeneous) expressions
|
|
|
|
macro_rules! ident_map {
|
|
|
|
( $name:ident = { $($key:ident => $e:expr,)* } ) => {
|
|
|
|
macro_rules! $name {
|
|
|
|
$(
|
|
|
|
( $key ) => { $e };
|
|
|
|
)*
|
|
|
|
// Empty invocation expands to nothing. Needed when the map is empty.
|
|
|
|
() => {};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
ident_map!(my_map = {
|
|
|
|
main => 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
my_map!(main);
|
|
|
|
}
|