pub struct Discriminant<'a> {
pub value: &'a [u8],
}
Expand description
Discriminant of an enum variant.
The Discriminant
value can be constructed using the discriminant!
macro.
Fields§
§value: &'a [u8]
The numeric value of the discriminant.
The value is stored in negabinary representation in little-endian
order as a byte array. Unlike the two’s complement representation,
negabinary has a unique representation for signed and unsigned
numbers that is independent of the size of the value type (e.g. i16
vs u64
).
Specifically,
- the
(-2)^0
th digit is stored in the least significant bit ofvalue[0]
- the
(-2)^7
th digit is stored in the most significant bit ofvalue[0]
- the
(-2)^8
th digit is stored in the least significant bit ofvalue[1]
- for all
i >= value.len()
,value[i]
is implicitly all-zero
Trait Implementations§
Source§impl<'a> Clone for Discriminant<'a>
impl<'a> Clone for Discriminant<'a>
Source§fn clone(&self) -> Discriminant<'a>
fn clone(&self) -> Discriminant<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for Discriminant<'a>
impl<'a> Debug for Discriminant<'a>
Source§impl<'de: 'a, 'a> Deserialize<'de> for Discriminant<'a>
impl<'de: 'a, 'a> Deserialize<'de> for Discriminant<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a> Hash for Discriminant<'a>
impl<'a> Hash for Discriminant<'a>
Source§impl<'a> Ord for Discriminant<'a>
impl<'a> Ord for Discriminant<'a>
Source§fn cmp(&self, other: &Discriminant<'a>) -> Ordering
fn cmp(&self, other: &Discriminant<'a>) -> Ordering
1.21.0 · 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
Source§impl<'a> PartialEq for Discriminant<'a>
impl<'a> PartialEq for Discriminant<'a>
Source§impl<'a> PartialOrd for Discriminant<'a>
impl<'a> PartialOrd for Discriminant<'a>
Source§impl<'a> Serialize for Discriminant<'a>
impl<'a> Serialize for Discriminant<'a>
impl<'a> Copy for Discriminant<'a>
impl<'a> Eq for Discriminant<'a>
impl<'a> StructuralPartialEq for Discriminant<'a>
Auto Trait Implementations§
impl<'a> Freeze for Discriminant<'a>
impl<'a> RefUnwindSafe for Discriminant<'a>
impl<'a> Send for Discriminant<'a>
impl<'a> Sync for Discriminant<'a>
impl<'a> Unpin for Discriminant<'a>
impl<'a> UnwindSafe for Discriminant<'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