pub struct VariantId { /* private fields */ }🔬This is a nightly-only experimental API. (
type_info)Expand description
Variant representing type ID. Representing a variant of an enum.
Implementations§
Source§impl VariantId
impl VariantId
Sourcepub const fn name(self) -> &'static str
🔬This is a nightly-only experimental API. (type_info)
pub const fn name(self) -> &'static str
type_info)Returns the name of the variant.
#![feature(type_info)]
use std::any::TypeId;
enum Enum {
Unit,
Tuple(bool),
Struct { a: bool },
}
assert_eq!(
const { TypeId::of::<Enum>().variant(1).name() },
"Tuple",
);Sourcepub const fn non_exhaustive(self) -> bool
🔬This is a nightly-only experimental API. (type_info)
pub const fn non_exhaustive(self) -> bool
type_info)Returns whether this variant is marked with #[non_exhaustive].
Trait Implementations§
impl Copy for VariantId
impl Eq for VariantId
Source§impl Ord for VariantId
impl Ord for VariantId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for VariantId
impl PartialOrd for VariantId
impl StructuralPartialEq for VariantId
Auto Trait Implementations§
impl Freeze for VariantId
impl RefUnwindSafe for VariantId
impl Send for VariantId
impl Sync for VariantId
impl Unpin for VariantId
impl UnsafeUnpin for VariantId
impl UnwindSafe for VariantId
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
Mutably borrows from an owned value. Read more