Add support for #[serde(default)], #[serde(default = "...")]#64
Open
dtzxporter wants to merge 1 commit intodtolnay:masterfrom
Open
Add support for #[serde(default)], #[serde(default = "...")]#64dtzxporter wants to merge 1 commit intodtolnay:masterfrom
dtzxporter wants to merge 1 commit intodtolnay:masterfrom
Conversation
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.
I fully understand that the point of this crate is to have limited customizability. I'm hoping you will consider support for at least the ability to deserialize optional fields (to their default values) with the derive. The main reason I think this makes sense is that because this crate targets json specifically, it's very common to have fields omitted, and implementing the trait manually just for the sake of injecting a default value seems overkill. My use case for miniserde is being able to serialize config data, without pulling in serde. Support for default makes it trivial to support the case where I want to extend the config, but still being backwards compatible, without manually implementing the trait for the config struct.
Feel free to make any changes necessary, I know that the parse is sub optimal since it runs for both the rename and default twice, but I wanted to get something rough first, and get a feel for if this would be merged before refining.