about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-03-05 04:46:38 +0100
committerGitHub <noreply@github.com>2022-03-05 04:46:38 +0100
commita3fe63e9fe73bea75c2405dd0928d78b5c83daf8 (patch)
tree7feb84d2d1f56db240779577e9f6b7d20f61b419
parentc7d200441b6dbc510cfe179ed0fc0ca94aa1e429 (diff)
parentf0257b1b4c76a23392c91db1b81754b85a9202c2 (diff)
downloadrust-a3fe63e9fe73bea75c2405dd0928d78b5c83daf8.tar.gz
rust-a3fe63e9fe73bea75c2405dd0928d78b5c83daf8.zip
Rollup merge of #94620 - pierwill:partialord-constistency, r=yaahc
Edit docs on consistency of `PartialOrd` and `PartialEq`

Use ordered list to make the information about implementations more readable.
-rw-r--r--library/core/src/cmp.rs25
1 files changed, 12 insertions, 13 deletions
diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs
index a3e77479911..ddaeb9eca97 100644
--- a/library/core/src/cmp.rs
+++ b/library/core/src/cmp.rs
@@ -885,19 +885,18 @@ impl PartialOrd for Ordering {
 /// The `lt`, `le`, `gt`, and `ge` methods of this trait can be called using
 /// the `<`, `<=`, `>`, and `>=` operators, respectively.
 ///
-/// The methods of this trait must be consistent with each other and with those of `PartialEq` in
-/// the following sense:
-///
-/// - `a == b` if and only if `partial_cmp(a, b) == Some(Equal)`.
-/// - `a < b` if and only if `partial_cmp(a, b) == Some(Less)`
-///   (ensured by the default implementation).
-/// - `a > b` if and only if `partial_cmp(a, b) == Some(Greater)`
-///   (ensured by the default implementation).
-/// - `a <= b` if and only if `a < b || a == b`
-///   (ensured by the default implementation).
-/// - `a >= b` if and only if `a > b || a == b`
-///   (ensured by the default implementation).
-/// - `a != b` if and only if `!(a == b)` (already part of `PartialEq`).
+/// The methods of this trait must be consistent with each other and with those of [`PartialEq`].
+/// The following conditions must hold:
+///
+/// 1. `a == b` if and only if `partial_cmp(a, b) == Some(Equal)`.
+/// 2. `a < b` if and only if `partial_cmp(a, b) == Some(Less)`
+/// 3. `a > b` if and only if `partial_cmp(a, b) == Some(Greater)`
+/// 4. `a <= b` if and only if `a < b || a == b`
+/// 5. `a >= b` if and only if `a > b || a == b`
+/// 6. `a != b` if and only if `!(a == b)`.
+///
+/// Conditions 2–5 above are ensured by the default implementation.
+/// Condition 6 is already ensured by [`PartialEq`].
 ///
 /// If [`Ord`] is also implemented for `Self` and `Rhs`, it must also be consistent with
 /// `partial_cmp` (see the documentation of that trait for the exact requirements). It's