Struct thrift::OrderedFloat

source ·
#[repr(transparent)]
pub struct OrderedFloat<T>(pub T) where T: Float;
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> OrderedFloat<T>
where T: Float,

source

pub fn into_inner(self) -> T

Get the value out.

Trait Implementations§

source§

impl<T> Add for OrderedFloat<T>
where T: Float,

§

type Output = OrderedFloat<T>

The resulting type after applying the + operator.
source§

fn add(self, other: OrderedFloat<T>) -> OrderedFloat<T>

Performs the + operation. Read more
source§

impl<T> AsMut<T> for OrderedFloat<T>
where T: Float,

source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<T> AsRef<T> for OrderedFloat<T>
where T: Float,

source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> Bounded for OrderedFloat<T>
where T: Float,

source§

fn min_value() -> OrderedFloat<T>

Returns the smallest finite number this type can represent
source§

fn max_value() -> OrderedFloat<T>

Returns the largest finite number this type can represent
source§

impl<T> Clone for OrderedFloat<T>
where T: Clone + Float,

source§

fn clone(&self) -> OrderedFloat<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for OrderedFloat<T>
where T: Debug + Float,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T> Default for OrderedFloat<T>
where T: Default + Float,

source§

fn default() -> OrderedFloat<T>

Returns the “default value” for a type. Read more
source§

impl<T> Deref for OrderedFloat<T>
where T: Float,

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &<OrderedFloat<T> as Deref>::Target

Dereferences the value.
source§

impl<T> DerefMut for OrderedFloat<T>
where T: Float,

source§

fn deref_mut(&mut self) -> &mut <OrderedFloat<T> as Deref>::Target

Mutably dereferences the value.
source§

impl<T> Display for OrderedFloat<T>
where T: Float + Display,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T> Div for OrderedFloat<T>
where T: Float,

§

type Output = OrderedFloat<T>

The resulting type after applying the / operator.
source§

fn div(self, other: OrderedFloat<T>) -> OrderedFloat<T>

Performs the / operation. Read more
source§

impl<T> From<T> for OrderedFloat<T>
where T: Float,

source§

fn from(val: T) -> OrderedFloat<T>

Converts to this type from the input type.
source§

impl<T> FromStr for OrderedFloat<T>
where T: Float + FromStr,

source§

fn from_str( s: &str, ) -> Result<OrderedFloat<T>, <OrderedFloat<T> as FromStr>::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());
§

type Err = <T as FromStr>::Err

The associated error which can be returned from parsing.
source§

impl<T> Hash for OrderedFloat<T>
where T: Float,

source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Into<f32> for OrderedFloat<f32>

source§

fn into(self) -> f32

Converts this type into the (usually inferred) input type.
source§

impl Into<f64> for OrderedFloat<f64>

source§

fn into(self) -> f64

Converts this type into the (usually inferred) input type.
source§

impl<T> Mul for OrderedFloat<T>
where T: Float,

§

type Output = OrderedFloat<T>

The resulting type after applying the * operator.
source§

fn mul(self, other: OrderedFloat<T>) -> OrderedFloat<T>

Performs the * operation. Read more
source§

impl<T> Neg for OrderedFloat<T>
where T: Float,

§

type Output = OrderedFloat<T>

The resulting type after applying the - operator.
source§

fn neg(self) -> OrderedFloat<T>

Performs the unary - operation. Read more
source§

impl<T> Ord for OrderedFloat<T>
where T: Float,

source§

fn cmp(&self, other: &OrderedFloat<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T> PartialEq for OrderedFloat<T>
where T: Float,

source§

fn eq(&self, other: &OrderedFloat<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> PartialOrd for OrderedFloat<T>
where T: Float,

source§

fn partial_cmp(&self, other: &OrderedFloat<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T> Sub for OrderedFloat<T>
where T: Float,

§

type Output = OrderedFloat<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: OrderedFloat<T>) -> OrderedFloat<T>

Performs the - operation. Read more
source§

impl<T> Zero for OrderedFloat<T>
where T: Float,

source§

fn zero() -> OrderedFloat<T>

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<T> Copy for OrderedFloat<T>
where T: Copy + Float,

source§

impl<T> Eq for OrderedFloat<T>
where T: Float,

Auto Trait Implementations§

§

impl<T> Freeze for OrderedFloat<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for OrderedFloat<T>
where T: RefUnwindSafe,

§

impl<T> Send for OrderedFloat<T>
where T: Send,

§

impl<T> Sync for OrderedFloat<T>
where T: Sync,

§

impl<T> Unpin for OrderedFloat<T>
where T: Unpin,

§

impl<T> UnwindSafe for OrderedFloat<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> LowerBounded for T
where T: Bounded,

source§

fn min_value() -> T

Returns the smallest finite number this type can represent
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UpperBounded for T
where T: Bounded,

source§

fn max_value() -> T

Returns the largest finite number this type can represent