Functionality for ordering and comparison.
This module defines both PartialOrd
and PartialEq
traits which are used by the compiler to implement comparison operators. Rust programs may implement PartialOrd
to overload the <
, <=
, >
, and >=
operators, and may implement PartialEq
to overload the ==
and !=
operators.
let x: u32 = 0; let y: u32 = 1; // these two lines are equivalent assert_eq!(x < y, true); assert_eq!(x.lt(&y), true); // these two lines are also equivalent assert_eq!(x == y, false); assert_eq!(x.eq(&y), false);
Ordering | An |
Eq | Trait for equality comparisons which are equivalence relations. |
Ord | Trait for types that form a total order. |
PartialEq | Trait for equality comparisons which are partial equivalence relations. |
PartialOrd | Trait for values that can be compared for a sort-order. |
max | Compare and return the maximum of two values. |
min | Compare and return the minimum of two values. |
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/cmp/index.html