Skip to main content

roster

Macro roster 

Source
macro_rules! roster {
    (
        $(#[$note:meta])*
        $vis:vis enum $name:ident {
            $( $(#[$row:meta])* $variant:ident = $declared:literal ),+ $(,)?
        }
    ) => { ... };
}
Expand description

Declares one closed vocabulary: the enum, its complete roster, and one declared name per row.

For a list of names and nothing else: a role is written by hand instead, because a role also names a destination and an implementation says that better than a stamp with an extra column.

ยงExamples

macroonz_compiler::roster! {
    /// Which direction a codec covers.
    pub enum Direction {
        /// Typed value to canonical bytes.
        Encode = "encode",
        /// Canonical bytes to typed value.
        Decode = "decode",
    }
}

assert_eq!(Direction::ALL, &[Direction::Encode, Direction::Decode]);
assert_eq!(Direction::Decode.name(), "decode");