2 releases

0.1.1 May 22, 2022
0.1.0 May 22, 2022

#1879 in Rust patterns

Download history 41/week @ 2024-04-02 2/week @ 2024-04-09 15/week @ 2024-04-16 79/week @ 2024-04-23 27/week @ 2024-04-30 13/week @ 2024-07-09 45/week @ 2024-07-16

58 downloads per month

Apache-2.0

6KB

enum_const

enum const trait

usage

use enum_const::EnumConst;

#[derive(EnumConst, PartialEq, Debug)]
enum Foo {
    X = 1,
    Y = 2,
    Z,
}

#[test]
fn it_works() {
    assert_eq!(Some(Foo::X), Foo::from_const_isize(1));
    assert_eq!(Some(1isize), Foo::X.get_const_isize());
}

Dependencies

~1.5MB
~35K SLoC