Make Rust serialize and ignore unrecognized settings, serialize false for boolean settings#10947
Draft
franknoirot wants to merge 6 commits intomainfrom
Draft
Make Rust serialize and ignore unrecognized settings, serialize false for boolean settings#10947franknoirot wants to merge 6 commits intomainfrom
false for boolean settings#10947franknoirot wants to merge 6 commits intomainfrom
Conversation
ZDS intention is that if the user doesn't set a setting, then it's not included in the file. The settings file should be for tracking what the user has explicitly chosen. It should not track defaults the user didn't choose. But right now, if the user explicitly chooses a setting which happens to be the default value (e.g. explicitly setting the length unit to mm), serde will skip serializing that field. The solution is to make most fields Option<T>, where if the user didn't set it, it's None. If the user did set it, then great, it'll be Some. And we only skip serializing if it's None. If it's Some, we serialize.
Now if the user sets another field that our schema doesn't know about, it will be read into Rust and serialized back to the output config file.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
dd4eddc to
1ee3577
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Authored primarily by @adamchalmers as he was on a huddle with me. This PR enables the serialization of boolean settings that are set to
false, and allows settings that are not defined in the Rust settings schema to be serialized but ignored. The first point solves buggy behavior with our app around toggling boolean settings, and the latter allows ZDS to define settings that are not available to the CLI. This is huge because we can have far more settings without the friction of needing CLI to care about them!. Closes #10397.