Skip to content

Commit b569cfc

Browse files
committed
Support casting values in libc_enum!
1 parent 28c5b4a commit b569cfc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/macros.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,23 @@ macro_rules! libc_enum {
379379
}
380380
};
381381

382+
// Munch an ident and cast it to the given type; covers terminating comma.
383+
(@accumulate_entries
384+
$prefix:tt,
385+
[$($entries:tt)*];
386+
$entry:ident as $ty:ty, $($tail:tt)*
387+
) => {
388+
libc_enum! {
389+
@accumulate_entries
390+
$prefix,
391+
[
392+
$($entries)*
393+
$entry = libc::$entry as $ty,
394+
];
395+
$($tail)*
396+
}
397+
};
398+
382399
// (non-pub) Entry rule.
383400
(
384401
$(#[$attr:meta])*

0 commit comments

Comments
 (0)