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:
commit
3ce6f6eca6
1 changed files with 5 additions and 3 deletions
|
@ -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`:
|
||||
|
|
Loading…
Add table
Reference in a new issue