Remove non_exhaustive from Book #2823
Merged
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.
This removes the
non_exhaustive
attribute from theBook
and its inner typesBookItem
andChapter
. These were added in #2779. After thinking about it more, I realized that these types cannot be extended in a semver-compatible way, so I am fine with allowing them be exhaustive.The problem is that with CmdPreprocessor, the
Book
will be re-serialized by a preprocessor, which could potentially be on an older version. Attempting to add any new fields/variants means that either the deserialization will fail, or the new fields will be stripped by the preprocessor.These could potentially be structured such that they have a
serde(flatten)
or Other/Unknown variant so that a preprocessor would at least see the extra fields/variants and pass them along back to the output. However, a preprocessor or renderer wouldn't know what to do with those new fields/variants (particularlyBookItem
) which would itself be a problem. It's still possible to do something like this in the future, but for now I think it's fine to restrict these to semver-major changes.