From b569cfc1e9bb3b665fb0d4c4fe1084bfa3feb6ba Mon Sep 17 00:00:00 2001 From: Bryant Mairs Date: Sun, 27 Aug 2017 09:02:02 -0700 Subject: Support casting values in libc_enum! --- src/macros.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/macros.rs b/src/macros.rs index 7a0eb07c..39bc466d 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -379,6 +379,23 @@ macro_rules! libc_enum { } }; + // Munch an ident and cast it to the given type; covers terminating comma. + (@accumulate_entries + $prefix:tt, + [$($entries:tt)*]; + $entry:ident as $ty:ty, $($tail:tt)* + ) => { + libc_enum! { + @accumulate_entries + $prefix, + [ + $($entries)* + $entry = libc::$entry as $ty, + ]; + $($tail)* + } + }; + // (non-pub) Entry rule. ( $(#[$attr:meta])* -- cgit v1.2.3