1
Fork 0

Rollup merge of #57496 - steveklabnik:gh32934, r=Centril

re-do docs for core::cmp

Fixes #32934
This commit is contained in:
Mazdak Farrokhzad 2019-01-13 05:26:55 +01:00 committed by GitHub
commit ce448f364a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,27 +1,22 @@
//! Functionality for ordering and comparison. //! Functionality for ordering and comparison.
//! //!
//! This module defines both [`PartialOrd`] and [`PartialEq`] traits which are used //! This module contains various tools for ordering and comparing values. In
//! by the compiler to implement comparison operators. Rust programs may //! summary:
//! implement [`PartialOrd`] to overload the `<`, `<=`, `>`, and `>=` operators,
//! and may implement [`PartialEq`] to overload the `==` and `!=` operators.
//! //!
//! [`PartialOrd`]: trait.PartialOrd.html //! * [`Eq`] and [`PartialEq`] are traits that allow you to define total and
//! [`PartialEq`]: trait.PartialEq.html //! 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`][cmp::Ordering] is an enum returned by the
//! main functions of [`Ord`] and [`PartialOrd`], and describes an ordering.
//! * [`Reverse`][cmp::Reverse] is a struct that allows you to easily reverse
//! an ordering.
//! * [`max`][cmp::max] and [`min`][cmp::min] are functions that build off of
//! [`Ord`] and allow you to find the maximum or minimum of two values.
//! //!
//! # Examples //! For more details, see the respective documentation of each item in the list.
//!
//! ```
//! 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);
//! ```
#![stable(feature = "rust1", since = "1.0.0")] #![stable(feature = "rust1", since = "1.0.0")]