1#[macro_export]
2macro_rules! def_const_type_enum {
9 ($vis:vis $name:ident => $ty:ty {
10 $($variant:ident => $val:expr),+
11 $(,)?
12 }) => {
13 #[non_exhaustive]
14 $vis struct $name;
15
16 impl $name {
17 $(
18 pub const $variant: $ty = $val;
19 )+
20
21 #[allow(dead_code)]
22 pub const VARIANTS: &'static [$ty] = &[$(Self::$variant),+];
23 }
24 };
25}
26
27#[macro_export]
28macro_rules! def_varied_type_enum {
35 ($vis:vis $name:ident {
36 $($variant:ident : $ty:ty => $val:expr),+
37 $(,)?
38 }) => {
39 #[non_exhaustive]
40 $vis struct $name;
41
42 impl $name {
43 $(
44 pub const $variant: $ty = $val;
45 )+
46
47 #[allow(dead_code)]
48 pub const VARIANTS: &'static [(&'static str, &'static dyn std::any::Any)] = &[
49 $((stringify!($variant), &$val as &dyn std::any::Any)),+
50 ];
51 }
52 };
53}