The Ord and Eq comparison traits

This module contains the definition of both Ord and Eq which define the common interfaces for doing comparison. Both are language items that the compiler uses to implement the comparison operators. Rust code may implement Ord to overload the <, <=, >, and >= operators, and Eq to overload the == and != operators.

Enum Ordering

Variants

Trait Eq

Trait for values that can be compared for equality and inequality.

This trait allows partial equality, where types can be unordered instead of strictly equal or unequal. For example, with the built-in floating-point types a == b and a != b will both evaluate to false if either a or b is NaN (cf. IEEE 754-2008 section 5.11).

Eventually, this will be implemented by default for types that implement TotalEq.

Method eq

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

Method ne

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

Trait Equiv

The equivalence relation. Two values may be equivalent even if they are of different types. The most common use case for this relation is container types; e.g. it is often desirable to be able to use &str values to look up entries in a container with ~str keys.

Method equiv

fn equiv(&self, other: &T) -> bool

Trait Ord

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

Eventually this may be simplified to only require an le method, with the others generated from default implementations. However it should remain possible to implement the others separately, for compatibility with floating-point NaN semantics (cf. IEEE 754-2008 section 5.11).

Method lt

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

Method le

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

Method ge

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

Method gt

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

Trait TotalEq

Trait for equality comparisons where a == b and a != b are strict inverses.

Method equals

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

Trait TotalOrd

Trait for types that form a total order

Method cmp

fn cmp(&self, other: &Self) -> Ordering

Implementation of TotalEq for bool

Method equals

fn equals(&self, other: &bool) -> bool

Implementation of TotalEq for u8

Method equals

fn equals(&self, other: &u8) -> bool

Implementation of TotalEq for u16

Method equals

fn equals(&self, other: &u16) -> bool

Implementation of TotalEq for u32

Method equals

fn equals(&self, other: &u32) -> bool

Implementation of TotalEq for u64

Method equals

fn equals(&self, other: &u64) -> bool

Implementation of TotalEq for i8

Method equals

fn equals(&self, other: &i8) -> bool

Implementation of TotalEq for i16

Method equals

fn equals(&self, other: &i16) -> bool

Implementation of TotalEq for i32

Method equals

fn equals(&self, other: &i32) -> bool

Implementation of TotalEq for i64

Method equals

fn equals(&self, other: &i64) -> bool

Implementation of TotalEq for int

Method equals

fn equals(&self, other: &int) -> bool

Implementation of TotalEq for uint

Method equals

fn equals(&self, other: &uint) -> bool

Implementation of ::core::cmp::Eq for Ordering

Method eq

fn eq(&self, __other: &Ordering) -> bool

Method ne

fn ne(&self, __other: &Ordering) -> bool

Implementation of TotalOrd for u8

Method cmp

fn cmp(&self, other: &u8) -> Ordering

Implementation of TotalOrd for u16

Method cmp

fn cmp(&self, other: &u16) -> Ordering

Implementation of TotalOrd for u32

Method cmp

fn cmp(&self, other: &u32) -> Ordering

Implementation of TotalOrd for u64

Method cmp

fn cmp(&self, other: &u64) -> Ordering

Implementation of TotalOrd for i8

Method cmp

fn cmp(&self, other: &i8) -> Ordering

Implementation of TotalOrd for i16

Method cmp

fn cmp(&self, other: &i16) -> Ordering

Implementation of TotalOrd for i32

Method cmp

fn cmp(&self, other: &i32) -> Ordering

Implementation of TotalOrd for i64

Method cmp

fn cmp(&self, other: &i64) -> Ordering

Implementation of TotalOrd for int

Method cmp

fn cmp(&self, other: &int) -> Ordering

Implementation of TotalOrd for uint

Method cmp

fn cmp(&self, other: &uint) -> Ordering

Function eq

fn eq<T: Eq>(v1: &T, v2: &T) -> bool

Function ge

fn ge<T: Ord>(v1: &T, v2: &T) -> bool

Function gt

fn gt<T: Ord>(v1: &T, v2: &T) -> bool

Function le

fn le<T: Ord>(v1: &T, v2: &T) -> bool

Function lt

fn lt<T: Ord>(v1: &T, v2: &T) -> bool

Function max

fn max<T: Ord>(v1: T, v2: T) -> T

Function min

fn min<T: Ord>(v1: T, v2: T) -> T

Function ne

fn ne<T: Eq>(v1: &T, v2: &T) -> bool