Struct ssb_legacy_msg_data::LegacyF64 [−][src]
pub struct LegacyF64(_);
Expand description
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.
Implementations
Safe conversion of an arbitrary f64 into a LegacyF64.
use ssb_legacy_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());
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_legacy_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) };
Checks whether a given f64
may be used as a LegacyF64.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for LegacyF64impl UnwindSafe for LegacyF64Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.