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

Improve http::Status by implementing traits via derive macro. #2850

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

frondeus
Copy link
Contributor

Main Reasoning

PartialEq when not implemented via derive macro, lacks StructuralPartialEq.

It causes undesired side effect, that the compiler rejects
constants like Status::Unauthorized to be used in pattern
(for example in the match expression)

Solution

Because the current manual implementation is trivial and matches
derived code 1:1, we can replace it with #[derive] without
changes in the behaviour

Fixes #2844

@SergioBenitez SergioBenitez force-pushed the frondeus/http_status_derive branch from 8ccefbb to f5c841c Compare August 19, 2024 22:50
`PartialEq` when not derived results in `StructuralPartialEq` not being
implemented. As this was the case for `http::Status`, matching against
constants like `Status::Unauthorized` was not allowed.

This commit replaces the manual implementations of equality traits
(`PartialEq`, `Eq`) and ordering traits (`PartialOrd`, `Ord`) for
`http::Status` with `#[derive]`.

Resolves rwf2#2844.
@SergioBenitez SergioBenitez force-pushed the frondeus/http_status_derive branch from f5c841c to 5d73d91 Compare August 19, 2024 22:51
@SergioBenitez SergioBenitez merged commit 8b9d906 into rwf2:master Aug 19, 2024
16 checks passed
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.

Implement PartialEq for http::Status with derive macro
2 participants