summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryant Mairs <bryant@mai.rs>2017-08-27 09:02:02 -0700
committerBryant Mairs <bryant@mai.rs>2017-08-27 09:05:59 -0700
commitb569cfc1e9bb3b665fb0d4c4fe1084bfa3feb6ba (patch)
tree05b9f7282e982e5cf8a27530d27d8289e3bc81aa
parent28c5b4a41a45a3ee5ec6c88927388b208f0449c3 (diff)
downloadnix-b569cfc1e9bb3b665fb0d4c4fe1084bfa3feb6ba.zip
Support casting values in libc_enum!
-rw-r--r--src/macros.rs17
1 files changed, 17 insertions, 0 deletions
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])*