devela::all

Macro ident_const_index

Source
macro_rules! ident_const_index {
    ( // without commas:
        // $vis: the visibility of the constants (pub, pub(super), …).
        // $total: the total number of identifiers.
        // $ident, $($rest),*: the list of identifiers.
        $vis:vis, $total:expr; $ident:ident $($rest:ident)*
    ) => { ... };
    ( // with commas:
        // $vis: the visibility of the constants (pub, pub(super), …).
        // $total: the total number of identifiers.
        // $ident, $($rest),*: the list of identifiers.
        $vis:vis, $total:expr; $ident:ident $(, $($rest:ident),* $(,)? )?
    ) => { ... };
}
Expand description

Defines a constant for every given identifier with a value of its index in the list.

§Examples

ident_const_index![pub, 3; first, second, third]; // with commas
assert![0 == first && 1 == second && 2 == third];

ident_const_index![pub(crate), 2; fourth fifth]; // without commas
assert![0 == fourth && 1 == fifth];