Trait std::ops::Eq

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 implies b == a (symmetry)
  • a == b and b == c implies a == c (transitivity)

[Eq], additionally implies:

  • a == a for every a (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.