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

feat!: make Error opaque #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

thomaseizinger
Copy link
Contributor

@thomaseizinger thomaseizinger commented Mar 20, 2023

As an effort towards #71, I propose to make Error an opaque struct. This allows us to rename variants, as well as add or remove some of them or change their internal representation without any breaking changes.

We lose the ability to match the specific one but that can be solved by adding is_ getters. Should we add them right away for all variants?

@mxinden
Copy link
Member

mxinden commented Mar 23, 2023

but that can be solved by adding is_ getters.

How are these different to a non-opaque struct with a non_exhaustive? Removing them would still be a breaking change, right?

Asked differently, why not just a non_exhaustive like on the std ErrorKind?

@thomaseizinger
Copy link
Contributor Author

but that can be solved by adding is_ getters.

How are these different to a non-opaque struct with a non_exhaustive? Removing them would still be a breaking change, right?

They can be more easily deprecated with fallback functionality. With an enum variant, you can only either return one or the other, meaning if you deprecate it, the user can't meaningfully migrate to something new because you can't emit "both".

With functions, you can deprecate one and have it call the new one internally.

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