pub trait Eq: PartialEq {
}
Expand description
Trait for comparing type instances corresponding to equivalence relations.
The difference between [Eq] and [PartialEq] is the additional requirement for reflexivity.
[PartialEq] guarantees symmetry and transitivity, but not reflexivity.
E.g., a type that implements [PartialEq] guarantees that for all a
, b
, and c
:
a == b
impliesb == a
(symmetry)a == b
andb == c
impliesa == c
(transitivity)
[Eq], additionally implies:
a == a
for everya
(reflexivity)
Reflexivity property cannot be checked by the compiler, and therefore Eq
does not have any methods, but only [PartialEq] as a supertrait.
Implementing [Eq] for a type that does not have reflexivity property is a logic error.