ToOrd

Trait ToOrd 

Source
pub trait ToOrd: Sized + Copy {
    type Ord: Ord;

    // Required method
    fn to_ord(self) -> Self::Ord;

    // Provided method
    fn total_eq(self, rhs: Self) -> bool { ... }
}
Expand description

A trait that converts a floating point number into something implementing total ordering.

The behavior of this trait is unspecified for NaN, and may result in a logic error.

Required Associated Types§

Source

type Ord: Ord

A type implementing total ordering, which a float can be trivially converted to.

The exact value of this associated type should be considered opaque, and is subject to change in minor releases.

Required Methods§

Source

fn to_ord(self) -> Self::Ord

Trivially converts this floating point number into one that implements total ordering. When implementing this, ensure that -0.0 == 0.0.

Behavior is usnpecified for NaN and may result in a logic error.

Provided Methods§

Source

fn total_eq(self, rhs: Self) -> bool

Checks two floating point numbers for total equality, ensuring that -0.0 == 0.0.

This has a default implementation based on to_ord. Only override this if you can provide a more performant implementation (benchmark!).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ToOrd for f32

Source§

type Ord = u32

Source§

fn to_ord(self) -> Self::Ord

Source§

fn total_eq(self, rhs: Self) -> bool

Source§

impl ToOrd for f64

Source§

type Ord = u64

Source§

fn to_ord(self) -> Self::Ord

Source§

fn total_eq(self, rhs: Self) -> bool

Implementors§