#enums #derive #enumeration

macro enum_from_derive

Implement From For the Enumeration

3 releases

0.1.5 Sep 6, 2024
0.1.4 Sep 5, 2024
0.1.3 Aug 23, 2024

#374 in Procedural macros

37 downloads per month

MIT/Apache

9KB
169 lines

enum_from_derive

Version info Downloads docs dependency status

example:

    use enum_from_derive::From;

    #[repr(i32)]
    #[derive(From, Debug)]
    pub enum Test {
        #[default]
        Name,
        #[from_str(test)]
        #[False]
        Test = 100,
        #[False]
        TTT,
        #[True]
        FFF = 1000
    }

    #[test]
    fn test() {
        let t = Test::from("test1");
        println!("{:?}", t);
        let t = Test::from(100);
        println!("{:?}", t);
        println!("{}", a.to_bool())
    }

Dependencies

~240–680KB
~16K SLoC