From ee35332b238ff015b7e023cdb3fc624bf841acfd Mon Sep 17 00:00:00 2001 From: Marrub Date: Mon, 18 Mar 2019 12:08:49 -0400 Subject: [PATCH] make c_enum use primitive repr --- source/durandal/cenum.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/durandal/cenum.rs b/source/durandal/cenum.rs index 62d4317..95186ac 100644 --- a/source/durandal/cenum.rs +++ b/source/durandal/cenum.rs @@ -36,16 +36,17 @@ macro_rules! c_enum { ( $(#[$outer:meta])* - $vi:vis enum $t:ident: $ti:ty + $vi:vis enum $t:ident: $ti:ident { - $($(#[$inner:meta])* $va:expr => $en:ident,)+ + $($va:expr => $en:ident,)+ } ) => { $(#[$outer])* + #[repr($ti)] #[derive(Copy, Clone, Eq, Ord, PartialEq, PartialOrd)] $vi enum $t { - $($en,)+ + $($en = $va,)+ } impl $t @@ -54,7 +55,7 @@ macro_rules! c_enum $vi fn from_repr(n: $ti) -> Result { match n { - $($(#[$inner])* $va => Ok($t::$en),)+ + $($va => Ok($t::$en),)+ n => Err(ReprError::new(n)) } }