2 releases

0.1.1 May 22, 2022
0.1.0 May 22, 2022

#2296 in Rust patterns

Download history 107/week @ 2024-07-22 17/week @ 2024-07-29 103/week @ 2024-08-05 73/week @ 2024-08-12 138/week @ 2024-08-19 123/week @ 2024-08-26 43/week @ 2024-09-02 35/week @ 2024-09-16 31/week @ 2024-09-23 121/week @ 2024-09-30 43/week @ 2024-10-07 71/week @ 2024-10-21 143/week @ 2024-10-28 217/week @ 2024-11-04

433 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
~38K SLoC