2 releases

0.1.1 May 22, 2022
0.1.0 May 22, 2022

#2316 in Rust patterns

Download history 142/week @ 2024-08-22 36/week @ 2024-08-29 13/week @ 2024-09-05 31/week @ 2024-09-12 18/week @ 2024-09-19 51/week @ 2024-09-26 116/week @ 2024-10-03 14/week @ 2024-10-10 44/week @ 2024-10-17 43/week @ 2024-10-24 271/week @ 2024-10-31 182/week @ 2024-11-07 292/week @ 2024-11-14 83/week @ 2024-11-21 203/week @ 2024-11-28 207/week @ 2024-12-05

855 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
~37K SLoC