Trait radians::ops::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!).

Implementations on Foreign Types§

source§

impl ToOrd for f32

§

type Ord = u32

source§

fn to_ord(self) -> <f32 as ToOrd>::Ord

source§

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

source§

impl ToOrd for f64

§

type Ord = u64

source§

fn to_ord(self) -> <f64 as ToOrd>::Ord

source§

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

Implementors§