]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
cc61c64b XL |
2 | /// A compile-time map from identifiers to arbitrary (heterogeneous) expressions |
3 | macro_rules! ident_map { | |
4 | ( $name:ident = { $($key:ident => $e:expr,)* } ) => { | |
5 | macro_rules! $name { | |
6 | $( | |
7 | ( $key ) => { $e }; | |
8 | )* | |
9 | // Empty invocation expands to nothing. Needed when the map is empty. | |
10 | () => {}; | |
11 | } | |
12 | }; | |
13 | } | |
14 | ||
15 | ident_map!(my_map = { | |
16 | main => 0, | |
17 | }); | |
18 | ||
7453a54e | 19 | fn main() { |
cc61c64b | 20 | my_map!(main); |
223e47cc | 21 | } |