macro_bits/gen_def.rs
1#[macro_export]
2/// Generate consts
3///
4/// ```
5/// use macro_bits::gen_consts;
6///
7/// gen_consts! {
8/// const_type: u8,
9/// A => 0x01,
10/// B => 0x02
11/// }
12/// assert_eq!(A, 0x01);
13/// ```
14macro_rules! gen_consts {
15 (
16 const_type: $const_type:ty,
17 $(
18 $const_ident:ident => $const_value:expr
19 ),*
20 ) => {
21 $(
22 pub const $const_ident: $const_type = $const_value;
23 )*
24 };
25}