Struct conjure_object::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
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
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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
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 more
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 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 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 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 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 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 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 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 usize
impl TryFrom<SafeLong> for usize
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<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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more