Trait core::cmp::PartialOrdUnstable [-]  [+] [src]

pub trait PartialOrd: PartialEq {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering>;

    fn lt(&self, other: &Self) -> bool { ... }
    fn le(&self, other: &Self) -> bool { ... }
    fn gt(&self, other: &Self) -> bool { ... }
    fn ge(&self, other: &Self) -> bool { ... }
}

Trait for values that can be compared for a sort-order.

PartialOrd only requires implementation of the partial_cmp method, with the others generated from default implementations.

However it remains possible to implement the others separately for types which do not have a total order. For example, for floating point numbers, NaN < 0 == false and NaN >= 0 == false (cf. IEEE 754-2008 section 5.11).

Required Methods

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

This method returns an ordering between self and other values if one exists.

Provided Methods

fn lt(&self, other: &Self) -> bool

This method tests less than (for self and other) and is used by the < operator.

fn le(&self, other: &Self) -> bool

This method tests less than or equal to (<=).

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

This method tests greater than (>).

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

This method tests greater than or equal to (>=).

Implementors