@@ -67,6 +67,10 @@ use self::Ordering::*;
67
67
/// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and
68
68
/// only if `a != b`.
69
69
///
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
+ ///
70
74
/// An example implementation for a domain in which two books are considered
71
75
/// the same book if their ISBN matches, even if the formats differ:
72
76
///
@@ -386,6 +390,10 @@ impl<T: Ord> Ord for Reverse<T> {
386
390
/// Then you must define an implementation for `cmp()`. You may find it useful to use
387
391
/// `cmp()` on your type's fields.
388
392
///
393
+ /// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must* agree with each other. It's
394
+ /// easy to accidentally make them disagree by deriving some of the traits and manually
395
+ /// implementing others.
396
+ ///
389
397
/// Here's an example where you want to sort people by height only, disregarding `id`
390
398
/// and `name`:
391
399
///
@@ -474,15 +482,19 @@ impl PartialOrd for Ordering {
474
482
///
475
483
/// ## How can I implement `PartialOrd`?
476
484
///
477
- /// PartialOrd only requires implementation of the `partial_cmp` method, with the others generated
478
- /// from default implementations.
485
+ /// ` PartialOrd` only requires implementation of the `partial_cmp` method, with the others
486
+ /// generated from default implementations.
479
487
///
480
488
/// However it remains possible to implement the others separately for types which do not have a
481
489
/// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 ==
482
490
/// false` (cf. IEEE 754-2008 section 5.11).
483
491
///
484
492
/// `PartialOrd` requires your type to be `PartialEq`.
485
493
///
494
+ /// Implementations of `PartialEq`, `PartialOrd`, and `Ord` *must* agree with each other. It's
495
+ /// easy to accidentally make them disagree by deriving some of the traits and manually
496
+ /// implementing others.
497
+ ///
486
498
/// If your type is `Ord`, you can implement `partial_cmp()` by using `cmp()`:
487
499
///
488
500
/// ```
0 commit comments