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
This commit is contained in:
bors 2018-12-30 13:24:11 +00:00
commit 3ce6f6eca6

View file

@ -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`: