Skip to content

Should serde_as apply default when the field is of type Option<_> #185

@jonasbb

Description

@jonasbb

Using deserialize_with or serde_as on a Option field makes them mandatory while deserializing. In order to make the behavior match more closely with the default serde behavior, serde_as could apply the default attribute on the field. This would make the field optional again while deserializing.

The downside would be that is complicates the macro and would introduce additional behavior.
Right now it only translates the serde_as attribute into serde's deserialize_with and serialize_with.

Originally proposed in #183
Related to #184

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions