ramon54321 / enum_index

Enum index macro for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EnumIndex

EnumIndex provides a small macro which implements EnumIndexGet, permitting the following:

use enum_index_repr::{EnumIndex, EnumIndexGet};

#[repr(u16)]
#[derive(EnumIndex)]
enum Tag {
    Hello,
    World,
    How,
    Are,
    You,
}

fn main() {
    assert_eq!(Tag::How.index(), 2);
}

About

Enum index macro for Rust


Languages

Language:Rust 100.0%