Skip to content

RUST-1370 Only check specific fields for hello equality #892

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

Merged
merged 2 commits into from
Jun 12, 2023

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Jun 9, 2023

No description provided.

@abr-egn abr-egn requested a review from isabelatkinson June 9, 2023 17:14
Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

It looks like the only place we were using our PartialEq implementation for HelloCommandResponse was the deleted code on line 151. I'm not sure the reasoning behind the way it was implemented the first time around, but I would guess it was custom logic for server description equality checks so I think we'd be fine to revamp that impl rather than add a new method for equality checking. We'd just want to add a comment similar to the one you added in this PR. As a side note, something I happened to discover today was this pattern:

#[derive(Derivative)]
#[derivative(PartialEq)]
struct A {
    pub x: i32,
    pub y: String,
    #[derivative(PartialEq = "ignore")]
    pub z: Option<f64>,
}

which might be a little bit more maintainable than a manual implementation of the trait if we're not skipping too many fields.

@abr-egn
Copy link
Contributor Author

abr-egn commented Jun 12, 2023

I think the reason it's not using Derivative is because server_type() has non-trivial logic so it's not just a field-by-field compare. I'd like to keep the logic for server description comparison specific to that rather than making it the general PartialEq impl since that seems easy to accidentally use elsewhere.

Good point that the impl was only used in the removed code, deleted it :)

@abr-egn abr-egn requested a review from isabelatkinson June 12, 2023 15:10
@abr-egn abr-egn merged commit cb24f4a into mongodb:main Jun 12, 2023
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.

2 participants