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 = 1.cmp(2);
assert_eq!(Ordering::Less, result);

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

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

Trait Implementations

impl PartialEq for Ordering
fn eq(value: any, value1: any) -> bool

Compare two values for equality.

Examples

assert_eq!(1.eq(2), false);
assert_eq!(2.eq(2), true);
assert_eq!(2.eq(1), false);
fn ne(value: any, value1: any) -> bool

Compare two values for inequality.

Examples

assert_eq!(1.ne(2), true);
assert_eq!(2.ne(2), false);
assert_eq!(2.ne(1), true);
impl Eq for Ordering

Protocols

protocol IS_VARIANT

Test if the provided argument is a variant.

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 DEBUG_FMT
format!("{:?}", value)

Debug format Ordering.

Examples

use std::cmp::Ordering;

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