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§
§impl Numeric
impl Numeric
pub fn validate(self) -> Result<Numeric, Error>
pub fn validate(self) -> Result<Numeric, Error>
Ensures this value contains a valid value.
Errors
Error::NotANumber
is returned if this contains a NaN floating point
value.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.