consistency

png-branch
an 2019-03-05 01:05:01 -05:00
parent f3e98c0c05
commit 7d0dc07e0b
1 changed files with 10 additions and 10 deletions

View File

@ -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<E, ReprError>`.
/// 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<Self, ReprError>
$vi fn from_repr(n: $ti) -> Result<Self, ReprError>
{
match n {
$($value => Ok($E::$Enum),)+
n => Err(ReprError::new(n))
$($va => Ok($t::$en),)+
n => Err(ReprError::new(n))
}
}
}