diff --git a/source/durandal/cenum.rs b/source/durandal/cenum.rs index f3c7ed2..56b8377 100644 --- a/source/durandal/cenum.rs +++ b/source/durandal/cenum.rs @@ -6,8 +6,8 @@ /// The syntax is similar to the `bitflags` macro, but each value has the /// syntax `value => enumeration`. `enum` is used instead of `struct`. /// -/// This will generate an `enum E` as well as a function `E::from_repr` which -/// will return `Result`. +/// This will generate an `enum $t` as well as a function `$t::from_repr` which +/// will return `Result<$t, ReprError>`. /// /// # Examples /// @@ -36,26 +36,26 @@ macro_rules! c_enum { ( $(#[$outer:meta])* - $V:vis enum $E:ident: $T:ty + $vi:vis enum $t:ident: $ti:ty { - $($value:expr => $Enum:ident,)+ + $($va:expr => $en:ident,)+ } ) => { $(#[$outer])* #[derive(Copy, Clone)] - $V enum $E + $vi enum $t { - $($Enum,)+ + $($en,)+ } - impl $E + impl $t { /// Returns, if representable, the variant of `Self` from `n`. - $V fn from_repr(n: $T) -> Result + $vi fn from_repr(n: $ti) -> Result { match n { - $($value => Ok($E::$Enum),)+ - n => Err(ReprError::new(n)) + $($va => Ok($t::$en),)+ + n => Err(ReprError::new(n)) } } }