Enum ::std::cmp::Ordering

Overview

An Ordering is the result of a comparison between two values.

Examples

use std::cmp::Ordering;
use std::ops::cmp;

let result = cmp(1, 2);
assert_eq!(Ordering::Less, result);

let result = cmp(1, 1);
assert_eq!(Ordering::Equal, result);

let result = cmp(2, 1);
assert_eq!(Ordering::Greater, result);

Variants

An ordering where a compared value is less than another.

An ordering where a compared value is equal to another.

An ordering where a compared value is greater than another.

Protocols

protocol partial_eq
if value == b { }

Perform a partial ordering equality test.

Examples

use std::cmp::Ordering;

assert!(Ordering::Less == Ordering::Less);
assert!(Ordering::Less != Ordering::Equal);
protocol eq
if value == b { }

Perform a total ordering equality test.

Examples

use std::ops::eq;
use std::cmp::Ordering;

assert!(eq(Ordering::Less, Ordering::Less));
assert!(!eq(Ordering::Less, Ordering::Equal));
protocol string_debug
println("{:?}", value)

Debug format Ordering.

Examples

use std::cmp::Ordering;

assert_eq!(format!("{:?}", Ordering::Less), "Less");