Suggest PartialEq impls are symmetric when possible #235
Replies: 1 comment
-
My personal opinion is that recommending symmetry seems ok, but it could also be possible to paper over non-symmetric impls more easily. You can locally reason about whether a symmetric impl for a concrete Transitivity doesn't seem like a reasonable requirement you can actually satisfy, since it's non local you'd be effectively picking some arbitrarily reachable types to add transitive equality impls for. Maybe a guideline for public APIs could be to consider useful |
Beta Was this translation helpful? Give feedback.
-
rust-lang/rust#81198 suggests removing the symmetry and transitivity contracts from
PartialEq
's standard library documentation. It has some examples of how these requirements can be difficult or undesirable in practice.That doesn't mean there isn't necessarily an API Guideline to consider for
PartialEq
on public items. Should we recommend corresponding symmetric and transitive impls ofPartialEq
exist when it's possible to add them?Beta Was this translation helpful? Give feedback.
All reactions