@@ -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
///
@@ -343,6 +347,10 @@ impl Ordering {
343
347
/// Then you must define an implementation for `cmp()`. You may find it useful to use
344
348
/// `cmp()` on your type's fields.
345
349
///
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
+ ///
346
354
/// Here's an example where you want to sort people by height only, disregarding `id`
347
355
/// and `name`:
348
356
///
@@ -431,15 +439,19 @@ impl PartialOrd for Ordering {
431
439
///
432
440
/// ## How can I implement `PartialOrd`?
433
441
///
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.
436
444
///
437
445
/// However it remains possible to implement the others separately for types which do not have a
438
446
/// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 ==
439
447
/// false` (cf. IEEE 754-2008 section 5.11).
440
448
///
441
449
/// `PartialOrd` requires your type to be `PartialEq`.
442
450
///
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
+ ///
443
455
/// If your type is `Ord`, you can implement `partial_cmp()` by using `cmp()`:
444
456
///
445
457
/// ```
0 commit comments