pub struct Variant { /* private fields */ }Expand description
A value that exists in one of multiple possible states. Each state may optionally have a type associated with it.
Implementations§
Source§impl Variant
impl Variant
Sourcepub fn new(
ty: VariantType,
discriminant: usize,
value: Option<Value>,
) -> Result<Self>
pub fn new( ty: VariantType, discriminant: usize, value: Option<Value>, ) -> Result<Self>
Creates a new variant for the given discriminant and optional value. The value’s type must match the variant’s type for the selected state.
Sourcepub fn discriminant(&self) -> usize
pub fn discriminant(&self) -> usize
Gets the index that describes in which state this value exists.
Sourcepub fn value(&self) -> Option<Value>
pub fn value(&self) -> Option<Value>
Gets the typed value associated with the current state, if any.
Sourcepub fn ty(&self) -> VariantType
pub fn ty(&self) -> VariantType
Gets the type of this value.
Trait Implementations§
impl StructuralPartialEq for Variant
Auto Trait Implementations§
impl Freeze for Variant
impl !RefUnwindSafe for Variant
impl Send for Variant
impl Sync for Variant
impl Unpin for Variant
impl !UnwindSafe for Variant
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