#enums #derive #enumeration

macro enum_from_derive

Implement From For the Enumeration

3 releases

0.1.6 Nov 15, 2024
0.1.5 Sep 6, 2024
0.1.3 Aug 23, 2024

#515 in Procedural macros

Download history 371/week @ 2024-08-19 10/week @ 2024-08-26 273/week @ 2024-09-02 19/week @ 2024-09-16 11/week @ 2024-09-23 5/week @ 2024-09-30 2/week @ 2024-10-07 113/week @ 2024-11-11 22/week @ 2024-11-18

135 downloads per month

MIT/Apache

10KB
197 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

~230–680KB
~16K SLoC