#[repr(C)]pub struct UnsizedEnum<B, V0: ?Sized, V1> { /* private fields */ }Expand description
An unsized enum with two variants
As this is a DST, this enum can only be created on the heap. So
for convenience, it allows a common base structure to be included
in the header before the enum variants. Also, since a lot of
space will generally be wasted by the discriminant due to
alignment and packing (even if it is only a u8), a whole usize
is used and the higher bits in the discriminant are made available
to the caller for storage.
The type parameters are: the common base type, the first variant (which may be unsized) and the second variant (which must be sized).
Implementations§
Source§impl<B, V0, V1> UnsizedEnum<B, V0, V1>
impl<B, V0, V1> UnsizedEnum<B, V0, V1>
Source§impl<B, V0: ?Sized, V1> UnsizedEnum<B, V0, V1>
impl<B, V0: ?Sized, V1> UnsizedEnum<B, V0, V1>
Sourcepub fn set_spare(&mut self, spare: usize)
pub fn set_spare(&mut self, spare: usize)
Set a value in the spare bits above the discriminant. Bit 0 of this value will not be stored.
Sourcepub fn get_spare(&self) -> usize
pub fn get_spare(&self) -> usize
Gets the discriminant value including any value stored in the
spare bits above it. So bit 0 will be the disriminant (0 for
V0, 1 for V1), and the remaining bits will be whatever
value was saved by the most recent call to set_spare, or 0
initially.
Sourcepub fn set_v0(&mut self, v0: &Move<V0>)
pub fn set_v0(&mut self, v0: &Move<V0>)
Change the value stored in the enum to the provided V0
value, dropping the previous value (of whichever variant).