pub enum Number {
PosInt(u64),
NegInt(i64),
Float(f64),
}
Expand description
A number type that implements Javascript / JSON semantics, modeled on serde_json: https://docs.serde.rs/src/serde_json/number.rs.html#20-22
Variants§
PosInt(u64)
Unsigned 64-bit integer value.
NegInt(i64)
Signed 64-bit integer value. The wrapped value is always negative.
Float(f64)
64-bit floating-point value.
Implementations§
Source§impl Number
impl Number
Sourcepub fn to_f64_lossy(self) -> f64
pub fn to_f64_lossy(self) -> f64
Converts to an f64
lossily.
Use Number::try_from
to make the conversion only if it is not lossy.
Sourcepub fn to_f32_lossy(self) -> f32
pub fn to_f32_lossy(self) -> f32
Converts to an f32
lossily.
Use Number::try_from
to make the conversion only if it is not lossy.
Trait Implementations§
impl Copy for Number
impl StructuralPartialEq for Number
Auto Trait Implementations§
impl Freeze for Number
impl RefUnwindSafe for Number
impl Send for Number
impl Sync for Number
impl Unpin for Number
impl UnwindSafe for Number
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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>
Converts
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>
Converts
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