pub struct Enum {
pub name: Ident,
pub values: Vec<EnumValue>,
pub origin: Origin<ItemEnum>,
/* private fields */
}Expand description
A #[prebindgen] enum whose every alternative is fieldless — the C-style
shape, a named set of integers.
Distinct from Variant because the identity of a member here is the value
Rust assigns it, not where it sits: a C header re-states each = expr
and a Kotlin enum class entry is NAME(7). A sum has no such value, which
is why the two are separate entities rather than one with a dead field each.
Fields§
§name: Ident§values: Vec<EnumValue>Values in declaration order; values[i].index == i.
origin: Origin<ItemEnum>Implementations§
Source§impl Enum
impl Enum
Sourcepub fn discriminant_values(&self) -> Result<Vec<(&Ident, i64)>, &Ident>
pub fn discriminant_values(&self) -> Result<Vec<(&Ident, i64)>, &Ident>
Every value paired with the number Rust assigns it, or the first value whose discriminant could not be evaluated.
This is the numbering a destination language needs when it has no way to
reference a Rust constant: a Kotlin enum class entry is NAME(3), and
the generated int → value decode matches on the same numbers, so both
come from here and cannot drift. An Err is a refusal for that
consumer only — one that re-emits the source spelling never asks.
Trait Implementations§
Auto Trait Implementations§
impl !Send for Enum
impl !Sync for Enum
impl Freeze for Enum
impl RefUnwindSafe for Enum
impl Unpin for Enum
impl UnsafeUnpin for Enum
impl UnwindSafe for Enum
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more