Module cmp
Utilities for comparing and ordering values.
This module contains various tools for comparing and ordering values. In summary:
- [
PartialEq<Rhs>] overloads the==and!=operators. In cases whereRhs(the right hand side's type) isSelf, this trait corresponds to a partial equivalence relation. Eqindicates that the overloaded==operator corresponds to an equivalence relation.OrdandPartialOrdare traits that allow you to define total and partial orderings between values, respectively. Implementing them overloads the<,<=,>, and>=operators.Orderingis an enum returned by the main functions ofOrdandPartialOrd, and describes an ordering of two values (less, equal, or greater).Reverseis a struct that allows you to easily reverse an ordering.maxandminare functions that build off ofOrdand allow you to find the maximum or minimum of two values.
For more details, see the respective documentation of each item in the list.
Modules
Structs
- AssertParamIsEq
-
KeyAndValue
A pair where ordering and equality work on only the
key, ignoring thevalue. - Reverse A helper struct for reverse ordering.
Enums
-
Ordering
An
Orderingis the result of a comparison between two values.
Traits
- Eq Trait for comparisons corresponding to equivalence relations.
-
HomogeneousTuple
Implementation detail for
smallestandlargest. Marker indicating thatSelfis a tuple where all members are of the same type. -
LargestArgs
Implementation detail for
largest. - Ord Trait for types that form a total order.
- PartialEq Trait for comparisons using the equality operator.
- PartialOrd Trait for types that form a partial order.
-
SmallestArgs
Implementation detail for
smallest.
Functions
- default_chaining_impl
- largest Compares and returns the maximum of the provided values.
- max Compares and returns the maximum of two values.
- max_by Returns the maximum of two values with respect to the specified comparison function.
- max_by_key Returns the element that gives the maximum value from the specified function.
- min Compares and returns the minimum of two values.
- min_by Returns the minimum of two values with respect to the specified comparison function.
- min_by_key Returns the element that gives the minimum value from the specified function.
- minmax Compares and sorts two values, returning minimum and maximum.
- minmax_by Returns minimum and maximum values with respect to the specified comparison function.
- minmax_by_key Returns minimum and maximum values with respect to the specified key function.
- smallest Compares and returns the minimum of the provided values.
Macros
-
Eq
Derive macro generating an impl of the trait
Eq. The behavior of this macro is described in detail here. -
Ord
Derive macro generating an impl of the trait
Ord. The behavior of this macro is described in detail here. -
PartialEq
Derive macro generating an impl of the trait
PartialEq. The behavior of this macro is described in detail here. -
PartialOrd
Derive macro generating an impl of the trait
PartialOrd. The behavior of this macro is described in detail here. -
impl_for_tuples_up_to
Calls
macon lists of arguments from size0to1 + count($y). -
impl_homogeneous_tuple
Implements
HomogeneousTuplefor a provided tuple. -
impl_largest_args
Implements
LargestArgsfor a provided tuple if applicable. -
impl_smallest_args
Implements
SmallestArgsfor a provided tuple if applicable. -
impl_tuples
Calls each
macon lists of arguments from size zero to twelve.