Skip to content
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

Open
wants to merge 1 commit into
base: v0.8.x
Choose a base branch
from

Conversation

max-heller
Copy link

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.

Closes #2274

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-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.46%. Comparing base (833f146) to head (fb94684).

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.
📢 Have feedback on the report? Share it here.

@@ -26,7 +26,7 @@ mod imp {
#[allow(unused)]
pub use {
::core::{
assert_eq,
assert_eq, assert_ne,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did rustfmt perhaps miss this file? My intuition is that these two names should be on different lines.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised me too but that's how it seems to autoformat

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(If you put them on different lines it merges them)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants