@@ -67,6 +67,10 @@ use self::Ordering::*;
6767/// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and
6868/// only if `a != b`.
6969///
70+ /// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must* agree with
71+ /// each other. It's easy to accidentally make them disagree by deriving some
72+ /// of the traits and manually implementing others.
73+ ///
7074/// An example implementation for a domain in which two books are considered
7175/// the same book if their ISBN matches, even if the formats differ:
7276///
@@ -343,6 +347,10 @@ impl Ordering {
343347/// Then you must define an implementation for `cmp()`. You may find it useful to use
344348/// `cmp()` on your type's fields.
345349///
350+ /// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must* agree with each other. It's
351+ /// easy to accidentally make them disagree by deriving some of the traits and manually
352+ /// implementing others.
353+ ///
346354/// Here's an example where you want to sort people by height only, disregarding `id`
347355/// and `name`:
348356///
@@ -431,15 +439,19 @@ impl PartialOrd for Ordering {
431439///
432440/// ## How can I implement `PartialOrd`?
433441///
434- /// PartialOrd only requires implementation of the `partial_cmp` method, with the others generated
435- /// from default implementations.
442+ /// ` PartialOrd` only requires implementation of the `partial_cmp` method, with the others
443+ /// generated from default implementations.
436444///
437445/// However it remains possible to implement the others separately for types which do not have a
438446/// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 ==
439447/// false` (cf. IEEE 754-2008 section 5.11).
440448///
441449/// `PartialOrd` requires your type to be `PartialEq`.
442450///
451+ /// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must* agree with each other. It's
452+ /// easy to accidentally make them disagree by deriving some of the traits and manually
453+ /// implementing others.
454+ ///
443455/// If your type is `Ord`, you can implement `partial_cmp()` by using `cmp()`:
444456///
445457/// ```
0 commit comments