iddm / serde-aux

An auxiliary serde library providing helpful functions for serialisation and deserialisation for containers, struct fields and others.
MIT License
152 stars 26 forks source link

field_attributes: add `default_as_true` #23

Closed woodruffw closed 2 years ago

woodruffw commented 2 years ago

This adds a default_as_true helper, which allows Serde to default bool fields to true instead of false.

This has been brought up on Serde's side before, but has no upstream implementation. Some of the discussion is here: https://github.com/serde-rs/serde/issues/1030

iddm commented 2 years ago

Hi and thanks for your contribution!

Do you mind renaming default_as_true to just bool_true()? As the default part is already in the #[serde(default = .

woodruffw commented 2 years ago

Thanks for the review! Sure, that's a much better name. I'll make that change tonight.

woodruffw commented 2 years ago

Updated. Let me know if there's anything else I can do or change.

iddm commented 2 years ago

Thanks, and that's already enough. Have a nice day!

iddm commented 2 years ago

Published as 3.1.0, enjoy! And thanks again.