Macro type_val::def_type_val [] [src]

macro_rules! def_type_val {
    {$(#[$attr:meta])* type $name:ident: $type:ty = $value:expr; $($next:tt)*} => { ... };
    {$(#[$attr:meta])* pub type $name:ident: $type:ty = $value:expr; $($next:tt)*} => { ... };
    () => { ... };
}

This macro is used to implement the TypeVal trait. Any number of values can be initialized with a single invocation. Items prefixed by pub are public. Attributes to be applied to items in a block, including doc comments, should go above their targets.

Example

def_type_val! {
    type One: i32 = 1;
    #[derive(Clone, Copy)]
    type True: bool = true;
    /// Negative one
    pub type NegOne: i32 = -1;
    pub type False: bool = false;
 }
 
println!("One = {}, True = {}, NegOne = {}, False = {}",
    One::VAL,
    True::VAL,
    NegOne::VAL,
    False::VAL);