Struct ordered_float::OrderedFloat
source · #[repr(transparent)]pub struct OrderedFloat<T: Float>(pub T);
Expand description
A wrapper around Floats providing an implementation of Ord and Hash.
NaN is sorted as greater than all other values and equal to itself, in contradiction with the IEEE standard.
Tuple Fields§
§0: T
Implementations§
source§impl<T: Float> OrderedFloat<T>
impl<T: Float> OrderedFloat<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Get the value out.
Trait Implementations§
source§impl<T: Float> Add<OrderedFloat<T>> for OrderedFloat<T>
impl<T: Float> Add<OrderedFloat<T>> for OrderedFloat<T>
source§impl<T: Float> AsMut<T> for OrderedFloat<T>
impl<T: Float> AsMut<T> for OrderedFloat<T>
source§impl<T: Float> AsRef<T> for OrderedFloat<T>
impl<T: Float> AsRef<T> for OrderedFloat<T>
source§impl<T: Float> Bounded for OrderedFloat<T>
impl<T: Float> Bounded for OrderedFloat<T>
source§impl<T: Clone + Float> Clone for OrderedFloat<T>
impl<T: Clone + Float> Clone for OrderedFloat<T>
source§fn clone(&self) -> OrderedFloat<T>
fn clone(&self) -> OrderedFloat<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Default + Float> Default for OrderedFloat<T>
impl<T: Default + Float> Default for OrderedFloat<T>
source§fn default() -> OrderedFloat<T>
fn default() -> OrderedFloat<T>
Returns the “default value” for a type. Read more
source§impl<T: Float> Deref for OrderedFloat<T>
impl<T: Float> Deref for OrderedFloat<T>
source§impl<T: Float> DerefMut for OrderedFloat<T>
impl<T: Float> DerefMut for OrderedFloat<T>
source§impl<T: Float> Div<OrderedFloat<T>> for OrderedFloat<T>
impl<T: Float> Div<OrderedFloat<T>> for OrderedFloat<T>
source§impl<T: Float> From<T> for OrderedFloat<T>
impl<T: Float> From<T> for OrderedFloat<T>
source§impl<T: Float + FromStr> FromStr for OrderedFloat<T>
impl<T: Float + FromStr> FromStr for OrderedFloat<T>
source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Convert a &str to OrderedFloat
. Returns an error if the string fails to parse.
use ordered_float::OrderedFloat;
assert!("-10".parse::<OrderedFloat<f32>>().is_ok());
assert!("abc".parse::<OrderedFloat<f32>>().is_err());
assert!("NaN".parse::<OrderedFloat<f32>>().is_ok());
source§impl<T: Float> Hash for OrderedFloat<T>
impl<T: Float> Hash for OrderedFloat<T>
source§impl<T: Float> Mul<OrderedFloat<T>> for OrderedFloat<T>
impl<T: Float> Mul<OrderedFloat<T>> for OrderedFloat<T>
source§impl<T: Float> Neg for OrderedFloat<T>
impl<T: Float> Neg for OrderedFloat<T>
source§impl<T: Float> Ord for OrderedFloat<T>
impl<T: Float> Ord for OrderedFloat<T>
source§impl<T: Float> PartialEq<OrderedFloat<T>> for OrderedFloat<T>
impl<T: Float> PartialEq<OrderedFloat<T>> for OrderedFloat<T>
source§fn eq(&self, other: &OrderedFloat<T>) -> bool
fn eq(&self, other: &OrderedFloat<T>) -> bool
source§impl<T: Float> PartialOrd<OrderedFloat<T>> for OrderedFloat<T>
impl<T: Float> PartialOrd<OrderedFloat<T>> for OrderedFloat<T>
1.0.0 · source§fn 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