#arithmetic-operations #enums #bit #proc #data #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

#1783 in Procedural macros

22 downloads per month

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

~320–770KB
~18K SLoC