pub enum Numeric {
Integer(i64),
UnsignedInteger(u64),
Float(f64),
}Expand description
A numerical value.
Variants§
Integer(i64)
A 64-bit signed integer.
UnsignedInteger(u64)
A 64-bit unsigned integer.
Float(f64)
A 64-bit floating point number.
Implementations§
Source§impl Numeric
impl Numeric
Sourcepub fn validate(self) -> Result<Self, Error>
pub fn validate(self) -> Result<Self, Error>
Ensures this value contains a valid value.
§Errors
Error::NotANumber is returned if this contains a NaN floating point
value.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Returns this numeric as an i64. If this conversion cannot be done
without losing precision or overflowing, None will be returned.
Sourcepub fn as_i64_lossy(&self, saturating: bool) -> i64
pub fn as_i64_lossy(&self, saturating: bool) -> i64
Returns this numeric as an i64, allowing for precision to be lost if
the type was not an i64 originally. If saturating is true, the
conversion will not allow overflows.
Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Returns this numeric as an u64. If this conversion cannot be done
without losing precision or overflowing, None will be returned.
Sourcepub fn as_u64_lossy(&self, saturating: bool) -> u64
pub fn as_u64_lossy(&self, saturating: bool) -> u64
Returns this numeric as an u64, allowing for precision to be lost if
the type was not an i64 originally. If saturating is true, the
conversion will not allow overflows.
Sourcepub const fn as_f64(&self) -> Option<f64>
pub const fn as_f64(&self) -> Option<f64>
Returns this numeric as an f64. If this conversion cannot be done
without losing precision, None will be returned.
Sourcepub const fn as_f64_lossy(&self) -> f64
pub const fn as_f64_lossy(&self) -> f64
Returns this numeric as an f64, allowing for precision to be lost if
the type was not an f64 originally.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Numeric
impl<'de> Deserialize<'de> for Numeric
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>,
Source§impl TryFrom<Numeric> for f64
impl TryFrom<Numeric> for f64
Source§type Error = IncompatibleTypeError
type Error = IncompatibleTypeError
Source§impl TryFrom<Numeric> for i64
impl TryFrom<Numeric> for i64
Source§type Error = IncompatibleTypeError
type Error = IncompatibleTypeError
Source§impl TryFrom<Numeric> for u64
impl TryFrom<Numeric> for u64
Source§type Error = IncompatibleTypeError
type Error = IncompatibleTypeError
impl StructuralPartialEq for Numeric
Auto Trait Implementations§
impl Freeze for Numeric
impl RefUnwindSafe for Numeric
impl Send for Numeric
impl Sync for Numeric
impl Unpin for Numeric
impl UnwindSafe for Numeric
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more