Skip to content

Add support for #[serde(default)], #[serde(default = "...")]#64

Open
dtzxporter wants to merge 1 commit intodtolnay:masterfrom
dtzxporter:support-default-attribute
Open

Add support for #[serde(default)], #[serde(default = "...")]#64
dtzxporter wants to merge 1 commit intodtolnay:masterfrom
dtzxporter:support-default-attribute

Conversation

@dtzxporter
Copy link

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.

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.

1 participant