macro_rules! define_ranged_enum {
(@inner_count ; $sum:ty ; $fst:ident, ) => { ... };
(@inner_count ; $sum:ty ; $fst:ident, $($rest:ident,)*) => { ... };
(@inner_match_from ; $idx:expr; $sum:ty ; $($i:ty : $arm:ident)*; ) => { ... };
(@inner_match_from ; $idx:expr; $sum:ty ; $($i:ty : $arm:ident)*; $fst:ident, $($rest:ident,)*) => { ... };
(@inner_match_to ; $name:ident; $idx:expr; $sum:ty ; $($i:ty : $arm:ident)*; ) => { ... };
(@inner_match_to ; $name:ident; $idx:expr; $sum:ty ; $($i:ty : $arm:ident)*; $fst:ident, $($rest:ident,)*) => { ... };
($name:ident, Derive($($derive:ident),* $(,)?), $($x:ident),+ $(,)?) => { ... };
($name:ident, $($x:ident),+ $(,)?) => { ... };
}
Define a new enum which can be convered to and from a Ranged usize.
Example:
use ranged_num::{define_ranged_enum, UZeroTo};
define_ranged_enum!(Example, Derive(Debug, PartialEq, Eq), A, B, C);
let x: UZeroTo<_> = Example::A.into();
assert_eq!(x.value(), 0);
let x = x.wrapped_add(5);
let y: Example = x.into();
assert_eq!(y, Example::C);