pub struct Data<'a>(_);
Expand description
Stores values of variants and records.
Implementations
sourceimpl<'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
impl<'a> Copy 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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more