derive_more
derive_more copied to clipboard
Generate `PartialEq::ne()` (#163)
Part of #163
Follows #473
Synopsis
derive(PartialEq) in std generates only PartialEq::eq() method implementation in its expansion. This silently kills any potential performance benefits if the underlying types implement PartialEq::ne() more efficiently than the default implementation (!PartialEq::eq()).
Solution
Generate PartialEq::ne() implementation always as well, by structurally calling != operator instead of ==.
Additionally
Unfortunately, the assert_ne!() macro also doesn't call PartialEq::ne() or != operator inside its expansion, and only negates the equality check. Found this when running tests against a purposely incorrect PartialEq::ne() implementation. That's why the assert_ne!() macro is redefined in partial_eq tests as asset!(left != right).
Checklist
- [x] Documentation is updated
- [x] Tests are added/updated
- [x] CHANGELOG entry is added (if required)