Skip to content

Commit 3ce6f6e

Browse files
committed
Auto merge of #57204 - czipperz:ord_docs_must_agree, r=sfackler
Make std::cmp::Ord documentation specify what it means to agree with ParitalEq Resolves #57157
2 parents 7155690 + 445dadc commit 3ce6f6e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/libcore/cmp.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,11 @@ impl<T: Ord> Ord for Reverse<T> {
472472
/// Then you must define an implementation for `cmp()`. You may find it useful to use
473473
/// `cmp()` on your type's fields.
474474
///
475-
/// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must* agree with each other. It's
476-
/// easy to accidentally make them disagree by deriving some of the traits and manually
477-
/// implementing others.
475+
/// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must*
476+
/// agree with each other. That is, `a.cmp(b) == Ordering::Equal` if
477+
/// and only if `a == b` and `Some(a.cmp(b)) == a.partial_cmp(b)` for
478+
/// all `a` and `b`. It's easy to accidentally make them disagree by
479+
/// deriving some of the traits and manually implementing others.
478480
///
479481
/// Here's an example where you want to sort people by height only, disregarding `id`
480482
/// and `name`:

0 commit comments

Comments
 (0)