diff options
| author | bors <bors@rust-lang.org> | 2018-12-30 13:24:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-12-30 13:24:11 +0000 |
| commit | 3ce6f6eca6f0c6df09b8efd45b3eec7ea94d2b25 (patch) | |
| tree | 50ea96382d393e70d77c66c033aa2d9dfe01260c /src/libcore | |
| parent | 7155690ffcdf2ce325361bdb5b64ad69c043662f (diff) | |
| parent | 445dadca33f5109398d819dd4dd408c291d110fb (diff) | |
| download | rust-3ce6f6eca6f0c6df09b8efd45b3eec7ea94d2b25.tar.gz rust-3ce6f6eca6f0c6df09b8efd45b3eec7ea94d2b25.zip | |
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
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cmp.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 9336b130d1b..f420d0d00a4 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -472,9 +472,11 @@ impl<T: Ord> Ord for Reverse<T> { /// Then you must define an implementation for `cmp()`. You may find it useful to use /// `cmp()` on your type's fields. /// -/// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must* agree with each other. It's -/// easy to accidentally make them disagree by deriving some of the traits and manually -/// implementing others. +/// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must* +/// agree with each other. That is, `a.cmp(b) == Ordering::Equal` if +/// and only if `a == b` and `Some(a.cmp(b)) == a.partial_cmp(b)` for +/// all `a` and `b`. It's easy to accidentally make them disagree by +/// deriving some of the traits and manually implementing others. /// /// Here's an example where you want to sort people by height only, disregarding `id` /// and `name`: |
