#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

#331 in Procedural macros

Download history 185/week @ 2024-08-23 86/week @ 2024-08-30 190/week @ 2024-09-06 17/week @ 2024-09-13 12/week @ 2024-09-20 5/week @ 2024-09-27 3/week @ 2024-10-04 130/week @ 2024-11-15 5/week @ 2024-11-22 24/week @ 2024-12-06

159 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

~220–660KB
~16K SLoC