Macro bounded_integer::bounded_integer_impl [] [src]

macro_rules! bounded_integer_impl {
    ($ty:ty, $repr:ty, $min:path, $max:path) => { ... };
}

Implements BoundedInteger for a C-like enum with contiguous variants.

Uses std::mem::transmute to implement BoundedInteger::from_repr and as to implement BoundedInteger::to_repr.

Examples

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[repr(u8)]
enum TwoBit { Z0, P1, P2, P3 }
bounded_integer_impl!(TwoBit, u8, TwoBit::Z0, TwoBit::P3);