Introduce a skip_if_null
attribute
#118
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Problem
A common scenario when serializing structs is to skip fields that are
null
. Currently, you have to write your ownserialize
function and manually check nullable fields and then skip them, which is quite tedious to do when you have lots of these fields.Proposal
A
skip_if_null
attribute can be added that'll be definable by all types that can specify a block. When applied to an optional field of a struct (or an optional variant of a union, etc.), the field/variant will be serialized only when it's value is notnull
. For deserialization, if the final value we would have assigned to the final field/variant value isnull
, then we can just skip assigning the field.Alternatives
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: