Enum msr_core::ScalarValue
source · [−]#[non_exhaustive]
pub enum ScalarValue {
Bool(bool),
I8(i8),
U8(u8),
I16(i16),
U16(u16),
I32(i32),
U32(u32),
F32(f32),
I64(i64),
U64(u64),
F64(f64),
}
Expand description
Tagged union of scalar values
Numbers are always stored with 64-bit precision. Using smaller sizes would have no advantages regarding the size of this product type.
No conversions between signed/unsigned and integer/floating-point numbers to prevent using wrong types unintentionally! The same argument applies to boolean/integer conversions.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Bool(bool)
Boolean
I8(i8)
8-bit signed integer
U8(u8)
8-bit unsigned integer
I16(i16)
16-bit signed integer
U16(u16)
16-bit unsigned integer
I32(i32)
32-bit signed integer
U32(u32)
32-bit unsigned integer
F32(f32)
32-bit floating-point number (double precision)
I64(i64)
64-bit signed integer
U64(u64)
64-bit unsigned integer
F64(f64)
64-bit floating-point number (double precision)
Implementations
sourceimpl Value
impl Value
pub const fn from_bool(val: bool) -> Self
pub const fn from_i8(val: i8) -> Self
pub const fn from_u8(val: u8) -> Self
pub const fn from_i16(val: i16) -> Self
pub const fn from_u16(val: u16) -> Self
pub const fn from_i32(val: i32) -> Self
pub const fn from_u32(val: u32) -> Self
pub const fn from_i64(val: i64) -> Self
pub const fn from_u64(val: u64) -> Self
pub const fn from_f32(val: f32) -> Self
pub const fn from_f64(val: f64) -> Self
pub const fn to_bool(self) -> Option<bool>
pub fn to_i8(self) -> Option<i8>
pub fn to_u8(self) -> Option<u8>
pub fn to_i16(self) -> Option<i16>
pub fn to_u16(self) -> Option<u16>
pub fn to_i32(self) -> Option<i32>
pub fn to_u32(self) -> Option<u32>
pub fn to_i64(self) -> Option<i64>
pub fn to_u64(self) -> Option<u64>
pub fn to_f32(self) -> Option<f32>
pub fn to_f64(self) -> Option<f64>
Trait Implementations
sourceimpl PartialEq<Value> for Value
impl PartialEq<Value> for Value
impl Copy for Value
impl StructuralPartialEq for Value
Auto Trait Implementations
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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