Hide details of error implementation, to not make changes into breaking changes #57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in the office. Having errors simply be public enums with associated data makes the implementation details part of the public API. Then almost all changes to the error are breaking changes. Here I show two potential ways to implement errors so that their internals are hidden, but it's equally easy to match for a library consumer.
This is currently split into two commits, one per proposed solution. So view it per commit if you want to compare them. I personally like the second solution the best. That error implementation could fairly easily be generated by a macro. I'm sure we are not the first people to come to this conclusion, maybe there is such a macro crate on crates.io already?
This change is