macro_rules! c_enum {
($(
$(#[repr($repr:ty)])?
pub enum $ty_name:ident {
$($variant:ident $(= $value:expr)?,)+
}
)+) => { ... };
(@expand;
$(#[repr($repr:ty)])?
pub enum $ty_name:ident {
$($variant:ident $(= $value:expr)?,)+
}
) => { ... };
(@one; $_ty_name:ident; $_idx:expr;) => { ... };
(
@one; $ty_name:ident; $default_val:expr;
$variant:ident $(= $value:expr)?,
$($tail:tt)*
) => { ... };
(@ty $repr:ty) => { ... };
(@ty) => { ... };
}
Expand description
Represent a C enum as Rust constants and a type.
C enums can’t soundly be mapped to Rust enums since C enums are allowed to have duplicates or unlisted values, but this is UB in Rust. This enum doesn’t implement any traits, its main purpose is to calculate the correct enum values.
See https://github.com/rust-lang/libc/issues/4419 for more.