-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[derive] Implement an IntoBytes-based PartialEq/Eq derive #2285
Conversation
The standard library's derive for `PartialEq` generates a recursive descent into the fields of the type it is applied to. This commit adds a `ByteEq` derive that generates an optimized, byte-oriented `PartialEq` implementation -- and a corresponding `Eq` implementation -- for types that implement `IntoBytes`. Instead of a recursive descent, the generated implementation performs a single slice comparison of the bytes of the two values being compared.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## v0.8.x #2285 +/- ##
=======================================
Coverage 87.46% 87.46%
=======================================
Files 16 16
Lines 6134 6134
=======================================
Hits 5365 5365
Misses 769 769 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for doing this!
Co-authored-by: Joshua Liebow-Feeser <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that rustfmt didn't catch this — something to dig into, I think.
The standard library's derive for
PartialEq
generates a recursive descent into the fields of the type it is applied to. This commit adds aByteEq
derive that generates an optimized, byte-orientedPartialEq
implementation -- and a correspondingEq
implementation -- for types that implementIntoBytes
. Instead of a recursive descent, the generated implementation performs a single slice comparison of the bytes of the two values being compared.Closes #2274