Enum Num

Source
pub enum Num {
    F32(f32),
    F64(f64),
    Signed(i64),
    Unsigned(u64),
}
Expand description

A number type that encapsulates what integers and floats can be represented in MessagePack Rust

Variants§

§

F32(f32)

Num is backed by f32 storage.

§

F64(f64)

Num is backed by f64 storage.

§

Signed(i64)

Num is backed by i64 storage.

§

Unsigned(u64)

Num is backed by u64 storage.

Implementations§

Source§

impl Num

Source

pub fn fits<T>(&self) -> bool
where Num: NumTo<T>,

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8

Source

pub fn to<T>(&self) -> T
where Num: NumTo<T>,

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable

Trait Implementations§

Source§

impl Clone for Num

Source§

fn clone(&self) -> Num

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Num

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Num

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<f32> for Num

Source§

fn from(t: f32) -> Num

Converts to this type from the input type.
Source§

impl From<f64> for Num

Source§

fn from(t: f64) -> Num

Converts to this type from the input type.
Source§

impl From<i16> for Num

Source§

fn from(t: i16) -> Num

Converts to this type from the input type.
Source§

impl From<i32> for Num

Source§

fn from(t: i32) -> Num

Converts to this type from the input type.
Source§

impl From<i64> for Num

Source§

fn from(t: i64) -> Num

Converts to this type from the input type.
Source§

impl From<i8> for Num

Source§

fn from(t: i8) -> Num

Converts to this type from the input type.
Source§

impl From<isize> for Num

Source§

fn from(t: isize) -> Num

Converts to this type from the input type.
Source§

impl From<u16> for Num

Source§

fn from(t: u16) -> Num

Converts to this type from the input type.
Source§

impl From<u32> for Num

Source§

fn from(t: u32) -> Num

Converts to this type from the input type.
Source§

impl From<u64> for Num

Source§

fn from(t: u64) -> Num

Converts to this type from the input type.
Source§

impl From<u8> for Num

Source§

fn from(t: u8) -> Num

Converts to this type from the input type.
Source§

impl From<usize> for Num

Source§

fn from(t: usize) -> Num

Converts to this type from the input type.
Source§

impl NumTo<f32> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> f32

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<f64> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> f64

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<i128> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> i128

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<i16> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> i16

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<i32> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> i32

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<i64> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> i64

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<i8> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> i8

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<isize> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> isize

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<u128> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> u128

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<u16> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> u16

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<u32> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> u32

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<u64> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> u64

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<u8> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> u8

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl NumTo<usize> for Num

Source§

fn fits(&self) -> bool

Will this Num instance fit in the target type? Fits is defined as lossless conversion. E.g. an f64 value of 42.0 will fit in all rust data types, but a u16 value of 256 will not fit in a u8
Source§

fn to(&self) -> usize

Convert this Num instance into the destination type. If this instance is outside the bounds of the target type, it will be clamped to fit. Check fits() first if this is not desireable
Source§

impl PartialEq<f32> for Num

Source§

fn eq(&self, oth: &f32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f64> for Num

Source§

fn eq(&self, oth: &f64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i128> for Num

Source§

fn eq(&self, oth: &i128) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i16> for Num

Source§

fn eq(&self, oth: &i16) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i32> for Num

Source§

fn eq(&self, oth: &i32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i64> for Num

Source§

fn eq(&self, oth: &i64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i8> for Num

Source§

fn eq(&self, oth: &i8) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<isize> for Num

Source§

fn eq(&self, oth: &isize) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u128> for Num

Source§

fn eq(&self, oth: &u128) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u16> for Num

Source§

fn eq(&self, oth: &u16) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u32> for Num

Source§

fn eq(&self, oth: &u32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u64> for Num

Source§

fn eq(&self, oth: &u64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u8> for Num

Source§

fn eq(&self, oth: &u8) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<usize> for Num

Source§

fn eq(&self, oth: &usize) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Num

Source§

fn eq(&self, oth: &Num) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Num

Auto Trait Implementations§

§

impl Freeze for Num

§

impl RefUnwindSafe for Num

§

impl Send for Num

§

impl Sync for Num

§

impl Unpin for Num

§

impl UnwindSafe for Num

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.