Enum Ordering
enum Ordering
An Ordering is the result of a comparison between two values.
Examples
use Ordering;
assert_eq!;
assert_eq!;
assert_eq!;
Variants
-
Less An ordering where a compared value is less than another.
-
Equal An ordering where a compared value is equal to another.
-
Greater An ordering where a compared value is greater than another.
Implementations
impl Ordering
const fn is_eq(self: Self) -> boolReturns
trueif the ordering is theEqualvariant.Examples
use Ordering; assert_eq!; assert_eq!; assert_eq!;const fn is_ne(self: Self) -> boolReturns
trueif the ordering is not theEqualvariant.Examples
use Ordering; assert_eq!; assert_eq!; assert_eq!;const fn is_lt(self: Self) -> boolReturns
trueif the ordering is theLessvariant.Examples
use Ordering; assert_eq!; assert_eq!; assert_eq!;const fn is_gt(self: Self) -> boolReturns
trueif the ordering is theGreatervariant.Examples
use Ordering; assert_eq!; assert_eq!; assert_eq!;const fn is_le(self: Self) -> boolReturns
trueif the ordering is either theLessorEqualvariant.Examples
use Ordering; assert_eq!; assert_eq!; assert_eq!;const fn is_ge(self: Self) -> boolReturns
trueif the ordering is either theGreaterorEqualvariant.Examples
use Ordering; assert_eq!; assert_eq!; assert_eq!;const fn reverse(self: Self) -> OrderingReverses the
Ordering.LessbecomesGreater.GreaterbecomesLess.EqualbecomesEqual.
Examples
Basic behavior:
use Ordering; assert_eq!; assert_eq!; assert_eq!;This method can be used to reverse a comparison:
let data: &mut = &mut ; // sort the array from largest to smallest. data.sort_by; let b: &mut = &mut ; assert!;const fn then(self: Self, other: Ordering) -> OrderingChains two orderings.
Returns
selfwhen it's notEqual. Otherwise returnsother.Examples
use Ordering; let result = Equal.then; assert_eq!; let result = Less.then; assert_eq!; let result = Less.then; assert_eq!; let result = Equal.then; assert_eq!; let x: = ; let y: = ; let result = x.0.cmp.then.then; assert_eq!;const fn then_with<F>(self: Self, f: F) -> Ordering where F: ~const FnOnce() -> OrderingChains the ordering with the given function.
Returns
selfwhen it's notEqual. Otherwise callsfand returns the result.Examples
use Ordering; let result = Equal.then_with; assert_eq!; let result = Less.then_with; assert_eq!; let result = Less.then_with; assert_eq!; let result = Equal.then_with; assert_eq!; let x: = ; let y: = ; let result = x.0.cmp.then_with.then_with; assert_eq!;
impl Clone for Ordering
fn clone(self: &Self) -> Ordering
impl Copy for Ordering
impl Debug for Ordering
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
impl Eq for Ordering
impl Freeze for Ordering
impl Hash for Ordering
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl Ord for Ordering
fn cmp(self: &Self, other: &Ordering) -> $crate::cmp::Ordering
impl PartialEq for Ordering
fn eq(self: &Self, other: &Ordering) -> bool
impl PartialOrd for Ordering
fn partial_cmp(self: &Self, other: &Ordering) -> $crate::option::Option<$crate::cmp::Ordering>
impl RefUnwindSafe for Ordering
impl Send for Ordering
impl StructuralPartialEq for Ordering
impl Sync for Ordering
impl Unpin for Ordering
impl UnwindSafe for Ordering
impl<T> Any for Ordering
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Ordering
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Ordering
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Ordering
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Ordering
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for Ordering
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Ordering
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Ordering
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>