#enums #flags #attributes #macro #u32 #automatic #checked

macro auto-enum

Provides attribute macros for building enums which are convenient for use with FFI, along with "enum" flags

4 releases

Uses old Rust 2015

0.2.0-alpha1 Nov 25, 2018
0.1.2 Oct 27, 2018
0.1.1 Oct 27, 2018
0.1.0 Oct 26, 2018

#32 in #checked

Download history 86/week @ 2024-03-03 118/week @ 2024-03-10 102/week @ 2024-03-17 120/week @ 2024-03-24 136/week @ 2024-03-31 97/week @ 2024-04-07 116/week @ 2024-04-14 131/week @ 2024-04-21 112/week @ 2024-04-28 99/week @ 2024-05-05 101/week @ 2024-05-12 98/week @ 2024-05-19 110/week @ 2024-05-26 112/week @ 2024-06-02 94/week @ 2024-06-09 115/week @ 2024-06-16

452 downloads per month
Used in 4 crates (3 directly)

MIT license

32KB
739 lines

Provides automatic enum implementations that are convenient for working with FFI

#[macro_use]
extern crate auto_enum;
extern crate checked_enum;

#[auto_enum(u32, checked)]
pub enum SweepDirection {
    CounterClockwise = 0,
    Clockwise = 1,
}

assert_eq!(SweepDirection::from_u32(0), Some(SweepDirection::CounterClockwise));
#[macro_use]
extern crate auto_enum;

#[enum_flags(u32)]
pub enum BitmapOptions {
    TARGET = 0x1,
    CANNOT_DRAW = 0x2,
    CPU_READ = 0x4,
    GDI_COMPATIBLE = 0x8,
}

let flags = BitmapOptions::TARGET | BitmapOptions::GDI_COMPATIBLE;
assert!(flags.is_set(BitmapOptions::TARGET));
assert!(!flags.is_set(BitmapOptions::CPU_READ));

Dependencies

~2MB
~46K SLoC