Skip to content

Commit 8758083

Browse files
committed
Remove requirement that forces symmetric and transitive PartialEq impls to exist
1 parent cf04ae5 commit 8758083

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

library/core/src/cmp.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,18 @@ use self::Ordering::*;
3131
/// equivalence relation. For example, in floating point numbers `NaN != NaN`,
3232
/// so floating point types implement `PartialEq` but not [`trait@Eq`].
3333
///
34-
/// Formally, the equality must be (for all `a`, `b` and `c`):
34+
/// Formally, the equality must be (for all `a`, `b`, `c` of type `A`, `B`,
35+
/// `C`):
3536
///
36-
/// - symmetric: `a == b` implies `b == a`; and
37-
/// - transitive: `a == b` and `b == c` implies `a == c`.
37+
/// - **Symmetric**: if `A: PartialEq<B>` and `B: PartialEq<A>`, then **`a == b`
38+
/// implies `b == a`**; and
39+
///
40+
/// - **Transitive**: if `A: PartialEq<B>` and `B: PartialEq<C>` and `A:
41+
/// PartialEq<C>`, then **`a == b` and `b == c` implies `a == c`**.
3842
///
39-
/// Note that these requirements mean that the trait itself must be implemented
40-
/// symmetrically and transitively: if `T: PartialEq<U>` and `U: PartialEq<V>`
41-
/// then `U: PartialEq<T>` and `T: PartialEq<V>`.
43+
/// Note that the `B: PartialEq<A>` (symmetric) and `A: PartialEq<C>`
44+
/// (transitive) impls are not forced to exist, but these requirements apply
45+
/// whenever they do exist.
4246
///
4347
/// ## Derivable
4448
///

0 commit comments

Comments
 (0)