|
1 | 1 | //! Functionality for ordering and comparison.
|
2 | 2 | //!
|
3 |
| -//! This module defines both [`PartialOrd`] and [`PartialEq`] traits which are used |
4 |
| -//! by the compiler to implement comparison operators. Rust programs may |
5 |
| -//! implement [`PartialOrd`] to overload the `<`, `<=`, `>`, and `>=` operators, |
6 |
| -//! and may implement [`PartialEq`] to overload the `==` and `!=` operators. |
| 3 | +//! This module contains various tools for ordering and comparing values. In |
| 4 | +//! summary: |
7 | 5 | //!
|
8 |
| -//! [`PartialOrd`]: trait.PartialOrd.html |
9 |
| -//! [`PartialEq`]: trait.PartialEq.html |
| 6 | +//! * [`Eq`] and [`PartialEq`] are traits that allow you to define total and |
| 7 | +//! partial equality between values, respectively. Implementing them overloads |
| 8 | +//! the `==` and `!=` operators. |
| 9 | +//! * [`Ord`] and [`PartialOrd`] are traits that allow you to define total and |
| 10 | +//! partial orderings between values, respectively. Implementing them overloads |
| 11 | +//! the `<`, `<=`, `>`, and `>=` operators. |
| 12 | +//! * [`Ordering`][cmp::Ordering] is an enum returned by the |
| 13 | +//! main functions of [`Ord`] and [`PartialOrd`], and describes an ordering. |
| 14 | +//! * [`Reverse`][cmp::Reverse] is a struct that allows you to easily reverse |
| 15 | +//! an ordering. |
| 16 | +//! * [`max`][cmp::max] and [`min`][cmp::min] are functions that build off of |
| 17 | +//! [`Ord`] and allow you to find the maximum or minimum of two values. |
10 | 18 | //!
|
11 |
| -//! # Examples |
12 |
| -//! |
13 |
| -//! ``` |
14 |
| -//! let x: u32 = 0; |
15 |
| -//! let y: u32 = 1; |
16 |
| -//! |
17 |
| -//! // these two lines are equivalent |
18 |
| -//! assert_eq!(x < y, true); |
19 |
| -//! assert_eq!(x.lt(&y), true); |
20 |
| -//! |
21 |
| -//! // these two lines are also equivalent |
22 |
| -//! assert_eq!(x == y, false); |
23 |
| -//! assert_eq!(x.eq(&y), false); |
24 |
| -//! ``` |
| 19 | +//! For more details, see the respective documentation of each item in the list. |
25 | 20 |
|
26 | 21 | #![stable(feature = "rust1", since = "1.0.0")]
|
27 | 22 |
|
|
0 commit comments