[−][src]Struct ssb_json_msg_data::LegacyF64
A wrapper around f64
to indicate that the float is compatible with the ssb legacy message
data model, i.e. it is neither an infinity, nor -0.0
, nor a NaN
.
Because a LegacyF64
is never NaN
, it can implement Eq
and Ord
, which regular f64
can not.
To obtain the inner value, use the From<LegacyF64> for f64
impl.
Methods
impl LegacyF64
[src]
pub fn from_f64(f: f64) -> Option<LegacyF64>
[src]
Safe conversion of an arbitrary f64
into a LegacyF64
.
use ssb_json_msg_data::LegacyF64; assert!(LegacyF64::from_f64(0.0).is_some()); assert!(LegacyF64::from_f64(-1.1).is_some()); assert!(LegacyF64::from_f64(-0.0).is_none()); assert!(LegacyF64::from_f64(std::f64::INFINITY).is_none()); assert!(LegacyF64::from_f64(std::f64::NEG_INFINITY).is_none()); assert!(LegacyF64::from_f64(std::f64::NAN).is_none());
pub unsafe fn from_f64_unchecked(f: f64) -> LegacyF64
[src]
Wraps the given f64
as a LegacyF64
without checking if it is valid.
When the debug_assertions
feature is enabled (when compiling without optimizations),
this function panics when given an invalid f64
.
Safety
You must not pass infinity, negative infinity, negative zero or a NaN
to this
function. Any method on the resulting LegacyF64
could panic or exhibit undefined
behavior.
use ssb_json_msg_data::LegacyF64; let fine = unsafe { LegacyF64::from_f64_unchecked(1.1) }; // Never do this: // let everything_is_terrible = unsafe { LegacyF64::from_f64_unchecked(-0.0) };
pub fn is_valid(f: f64) -> bool
[src]
Checks whether a given f64
may be used as a LegacyF64
.
Trait Implementations
impl Clone for LegacyF64
[src]
impl Copy for LegacyF64
[src]
impl Debug for LegacyF64
[src]
impl Default for LegacyF64
[src]
impl<'de> Deserialize<'de> for LegacyF64
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for LegacyF64
[src]
impl Eq for LegacyF64
[src]
impl From<LegacyF64> for f64
[src]
impl Ord for LegacyF64
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<LegacyF64> for LegacyF64
[src]
impl PartialOrd<LegacyF64> for LegacyF64
[src]
fn partial_cmp(&self, other: &LegacyF64) -> Option<Ordering>
[src]
fn lt(&self, other: &LegacyF64) -> bool
[src]
fn le(&self, other: &LegacyF64) -> bool
[src]
fn gt(&self, other: &LegacyF64) -> bool
[src]
fn ge(&self, other: &LegacyF64) -> bool
[src]
impl Serialize for LegacyF64
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for LegacyF64
[src]
Auto Trait Implementations
impl RefUnwindSafe for LegacyF64
impl Send for LegacyF64
impl Sync for LegacyF64
impl Unpin for LegacyF64
impl UnwindSafe for LegacyF64
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,