#enums #flags #macro #attributes #u32 #checked #enum-flags

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

#29 in #u32

Download history 41/week @ 2023-11-20 38/week @ 2023-11-27 23/week @ 2023-12-04 50/week @ 2023-12-11 68/week @ 2023-12-18 42/week @ 2023-12-25 19/week @ 2024-01-01 48/week @ 2024-01-08 65/week @ 2024-01-15 42/week @ 2024-01-22 45/week @ 2024-01-29 39/week @ 2024-02-05 56/week @ 2024-02-12 92/week @ 2024-02-19 98/week @ 2024-02-26 101/week @ 2024-03-04

354 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
~45K SLoC