Skip to content

Clarify upfront that PartialOrd is for strict partial orders #140779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
//! * [`Eq`] indicates that the overloaded `==` operator corresponds to an
//! equivalence relation.
//! * [`Ord`] and [`PartialOrd`] are traits that allow you to define total and
//! partial orderings between values, respectively. Implementing them overloads
//! the `<`, `<=`, `>`, and `>=` operators.
//! strict partial orderings between values, respectively. Implementing them
//! overloads the `<`, `<=`, `>`, and `>=` operators.
//! * [`Ordering`] is an enum returned by the main functions of [`Ord`] and
//! [`PartialOrd`], and describes an ordering of two values (less, equal, or
//! greater).
Expand Down Expand Up @@ -1095,7 +1095,7 @@ pub macro Ord($item:item) {
/* compiler built-in */
}

/// Trait for types that form a [partial order](https://en.wikipedia.org/wiki/Partial_order).
/// Trait for types that form a [strict partial order](https://en.wikipedia.org/wiki/Strict_partial_order).
///
/// The `lt`, `le`, `gt`, and `ge` methods of this trait can be called using the `<`, `<=`, `>`, and
/// `>=` operators, respectively.
Expand Down Expand Up @@ -1163,7 +1163,8 @@ pub macro Ord($item:item) {
/// The following corollaries follow from the above requirements:
///
/// - irreflexivity of `<` and `>`: `!(a < a)`, `!(a > a)`
/// - transitivity of `>`: if `a > b` and `b > c` then `a > c`
/// - transitivity of `>`: if `a > b` and `b > c`, then `a > c`
/// - antisymmetry of `<=`: if `a <= b` and `b <= a`, then `a == b`
/// - duality of `partial_cmp`: `partial_cmp(a, b) == partial_cmp(b, a).map(Ordering::reverse)`
///
/// ## Strict and non-strict partial orders
Expand Down
Loading