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