Struct conjure_object::safe_long::SafeLong
source · [−]pub struct SafeLong(_);
Expand description
An i64 limited to a range safely representable in JSON.
JSON does not specify requirements of its numeric type, which can lead to issues interoperating between different JSON libraries and languages. In particular, some implementations (including Javascript) interpret numbers as double precision floating point values. Sufficiently large 64-bit integers are not exactly representable as doubles which can cause bugs as numbers change value as they’re transmitted from place to place.
The SafeLong
type wraps an i64, and avoids these issues by limiting its value to the range that is exactly
representable in a double: values between -253 + 1 and 253 - 1.
Implementations
Methods from Deref<Target = i64>
Trait Implementations
sourceimpl<'de> Deserialize<'de> for SafeLong
impl<'de> Deserialize<'de> for SafeLong
sourcefn deserialize<D>(d: D) -> Result<SafeLong, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<SafeLong, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl FromStr for SafeLong
impl FromStr for SafeLong
type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing.
sourceimpl Ord for SafeLong
impl Ord for SafeLong
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<SafeLong> for SafeLong
impl PartialOrd<SafeLong> for SafeLong
sourcefn partial_cmp(&self, other: &SafeLong) -> Option<Ordering>
fn partial_cmp(&self, other: &SafeLong) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl TryFrom<SafeLong> for i16
impl TryFrom<SafeLong> for i16
type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
sourceimpl TryFrom<SafeLong> for i32
impl TryFrom<SafeLong> for i32
type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
sourceimpl TryFrom<SafeLong> for i8
impl TryFrom<SafeLong> for i8
type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
sourceimpl TryFrom<SafeLong> for isize
impl TryFrom<SafeLong> for isize
type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
sourceimpl TryFrom<SafeLong> for u128
impl TryFrom<SafeLong> for u128
type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
sourceimpl TryFrom<SafeLong> for u16
impl TryFrom<SafeLong> for u16
type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
sourceimpl TryFrom<SafeLong> for u32
impl TryFrom<SafeLong> for u32
type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
sourceimpl TryFrom<SafeLong> for u64
impl TryFrom<SafeLong> for u64
type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
sourceimpl TryFrom<SafeLong> for u8
impl TryFrom<SafeLong> for u8
type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
sourceimpl TryFrom<SafeLong> for usize
impl TryFrom<SafeLong> for usize
type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
sourceimpl TryFrom<i128> for SafeLong
impl TryFrom<i128> for SafeLong
type Error = BoundsError
type Error = BoundsError
The type returned in the event of a conversion error.
sourceimpl TryFrom<i64> for SafeLong
impl TryFrom<i64> for SafeLong
type Error = BoundsError
type Error = BoundsError
The type returned in the event of a conversion error.
sourceimpl TryFrom<isize> for SafeLong
impl TryFrom<isize> for SafeLong
type Error = BoundsError
type Error = BoundsError
The type returned in the event of a conversion error.
sourceimpl TryFrom<u128> for SafeLong
impl TryFrom<u128> for SafeLong
type Error = BoundsError
type Error = BoundsError
The type returned in the event of a conversion error.
sourceimpl TryFrom<u64> for SafeLong
impl TryFrom<u64> for SafeLong
type Error = BoundsError
type Error = BoundsError
The type returned in the event of a conversion error.
sourceimpl TryFrom<usize> for SafeLong
impl TryFrom<usize> for SafeLong
type Error = BoundsError
type Error = BoundsError
The type returned in the event of a conversion error.
impl Copy for SafeLong
impl Eq for SafeLong
impl StructuralEq for SafeLong
impl StructuralPartialEq for SafeLong
Auto Trait Implementations
impl RefUnwindSafe for SafeLong
impl Send for SafeLong
impl Sync for SafeLong
impl Unpin for SafeLong
impl UnwindSafe for SafeLong
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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