pub struct SafeLong(/* private fields */);
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§
Source§impl<'de> Deserialize<'de> for SafeLong
impl<'de> Deserialize<'de> for SafeLong
Source§fn 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
Source§impl Ord for SafeLong
impl Ord for SafeLong
Source§impl PartialOrd for SafeLong
impl PartialOrd for SafeLong
impl Copy for SafeLong
impl Eq for SafeLong
impl StructuralPartialEq for SafeLong
Auto Trait Implementations§
impl Freeze for SafeLong
impl RefUnwindSafe for SafeLong
impl Send for SafeLong
impl Sync for SafeLong
impl Unpin for SafeLong
impl UnwindSafe for SafeLong
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