std::cmp - Rust
Description: API documentation for the Rust `cmp` mod in crate `std`.
Keywords: rust, rustlang, rust-lang, cmp

# Module std::cmp 1.0.0 [−] [src]

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.

# Examples

    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);Run

## Structs

Reverse | A helper struct for reverse ordering.

## Enums

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

## Traits

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.

## Functions

max | Compares and returns the maximum of two values.
min | Compares and returns the minimum of two values.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)