Module std::cmp

1.0.0 · source ·
Expand description

Utilities for comparing and ordering values.

This module contains various tools for comparing and ordering values. In summary:

  • Eq and PartialEq are traits that allow you to define total and partial equality between values, respectively. Implementing them overloads the == and != operators.
  • Ord and PartialOrd are traits that allow you to define total and partial orderings between values, respectively. Implementing them overloads the <, <=, >, and >= operators.
  • Ordering is an enum returned by the main functions of Ord and PartialOrd, and describes an ordering.
  • Reverse is a struct that allows you to easily reverse an ordering.
  • max and min are functions that build off of Ord and allow you to find the maximum or minimum of two values.

For more details, see the respective documentation of each item in the list.

Structs

Enums

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

Traits

Functions

  • Compares and returns the maximum of two values.
  • Returns the maximum of two values with respect to the specified comparison function.
  • Returns the element that gives the maximum value from the specified function.
  • Compares and returns the minimum of two values.
  • Returns the minimum of two values with respect to the specified comparison function.
  • Returns the element that gives the minimum value from the specified function.

Derive Macros

  • Derive macro generating an impl of the trait Eq.
  • Derive macro generating an impl of the trait Ord. The behavior of this macro is described in detail here.
  • Derive macro generating an impl of the trait PartialEq. The behavior of this macro is described in detail here.
  • Derive macro generating an impl of the trait PartialOrd. The behavior of this macro is described in detail here.