Skip to content

Commit cf3959c

Browse files
committed
Make std::cmp::Ord documentation specify what it means to agree with PartialEq
1 parent 43d26b1 commit cf3959c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/libcore/cmp.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,10 @@ 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`. It's easy to accidentally make them disagree
478+
/// by deriving some of the traits and manually implementing others.
478479
///
479480
/// Here's an example where you want to sort people by height only, disregarding `id`
480481
/// and `name`:

0 commit comments

Comments
 (0)