Skip to content

Commit 461244a

Browse files
authored
Rollup merge of #57496 - steveklabnik:gh32934, r=Centril
re-do docs for core::cmp Fixes #32934
2 parents 085d06c + 186d5d7 commit 461244a

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

src/libcore/cmp.rs

+15-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
//! Functionality for ordering and comparison.
22
//!
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:
75
//!
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.
1018
//!
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.
2520
2621
#![stable(feature = "rust1", since = "1.0.0")]
2722

0 commit comments

Comments
 (0)