pub struct Data<'a>(/* private fields */);
Expand description
Stores values of variants and records.
Implementations§
source§impl<'a> Data<'a>
impl<'a> Data<'a>
sourcepub fn tag(&self) -> VmTag
pub fn tag(&self) -> VmTag
The tag of this variant. If this value is a variant, the tag is the zero-based index of the variant that is present, in order of the declaration.
Use this method to find out what variant you are dealing with, before extracting data from it.
Examples
type OneOfFour =
| First
| Second
| Third
| Fourth
let val = First // has the tag '0'
let val = Fourth // has the tag '3'
sourcepub fn get(&self, index: usize) -> Option<ValueRef<'a>>
pub fn get(&self, index: usize) -> Option<ValueRef<'a>>
Retrieves the value of the field at index
, like get_variant
, but does not
wrap it in a Variants
struct.
sourcepub fn iter(&self) -> impl Iterator<Item = Variants<'a>>
pub fn iter(&self) -> impl Iterator<Item = Variants<'a>>
Creates an iterator over the fields of this value.
sourcepub fn get_variant(&self, index: usize) -> Option<Variants<'a>>
pub fn get_variant(&self, index: usize) -> Option<Variants<'a>>
Retrieves the value of the field at index
. This is useful if you cannot
name the field (like in a variant). If the value is a record, use
lookup_field
instead.
Trait Implementations§
source§impl<'a> PartialEq for Data<'a>
impl<'a> PartialEq for Data<'a>
impl<'a> StructuralPartialEq for Data<'a>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Data<'a>
impl<'a> Send for Data<'a>
impl<'a> Sync for Data<'a>
impl<'a> Unpin for Data<'a>
impl<'a> !UnwindSafe for Data<'a>
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
§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.