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

Add #[non_exhaustive] to relevant types #1614

Merged
merged 2 commits into from
Aug 25, 2022
Merged

Add #[non_exhaustive] to relevant types #1614

merged 2 commits into from
Aug 25, 2022

Conversation

SimonSapin
Copy link
Contributor

@SimonSapin SimonSapin commented Aug 25, 2022

… with a few exceptions like Location and PathElement.

Relevant types are:

  • Public enums
  • Public structs without any private field

See https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute

This will allow us adding struct fields or enum variants without it being a breaking change.

Fixes #1550

@SimonSapin SimonSapin added this to the v1.0.0-alpha.0 milestone Aug 25, 2022
@SimonSapin SimonSapin self-assigned this Aug 25, 2022
Copy link
Contributor

@o0Ignition0o o0Ignition0o left a comment

Choose a reason for hiding this comment

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

LGTM!

I especially like the thought you gave into changing visibility and tidying up the code a bit while you were at it <3

@@ -333,6 +334,7 @@ impl Server {
/// Listening address.
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)]
#[serde(untagged)]
#[non_exhaustive]
pub enum ListenAddr {
Copy link
Contributor

Choose a reason for hiding this comment

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

cant quite think of anything else, but non exhaustive is the safe bet anyway 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I’ve reverted this one. I was a bit too mechanical in adding it everywhere :)

… with a few exceptions like `Location` and `PathElement`.

Relevant types are:

* Public enums
* Public structs without any private field

See https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute

This will allow us adding struct fields or enum variants without it being a breaking change.
@SimonSapin SimonSapin enabled auto-merge (rebase) August 25, 2022 14:55
@SimonSapin SimonSapin merged commit 5102b6b into main Aug 25, 2022
@SimonSapin SimonSapin deleted the simon/exhaustive branch August 25, 2022 15:17
@abernix abernix mentioned this pull request Aug 29, 2022
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.

Make types #[non_exhaustive] for forward-compatibility
2 participants