#arithmetic-operations #enums #bit #data #proc #add #proc-macro

macro enum_data_proc

a proc-macro,Add bit operations and arithmetic operations to enum

1 unstable release

0.1.0 Jun 17, 2023

#2209 in Procedural macros

WTFPL license

10KB
196 lines

enum_data_proc

Add bit operations and arithmetic operations to enum

example

use enum_data_proc::*;

#[repr(u32)]
#[derive(BitOp,ArithOp)]
enum A{
    a=7,b,c,d,e,f,
}

fn main() {
    println!("{:?}",[
        A::a+1,
        A::b<<1,
        1&A::c,
        A::d|A::d,
        A::e%2,
        2*A::f]
    );
}

Dependencies

~225–670KB
~16K SLoC