serde icon indicating copy to clipboard operation
serde copied to clipboard

Document whether len passed to Serializer::serialize_struct includes skipped fields

Open dtolnay opened this issue 6 years ago • 1 comments

The documentation for Serializer::serialize_struct currently says:

len is the number of data fields that will be serialized.

This implies that the count of skipped field is not to be included in the len. It would be worth calling this out explicitly.

dtolnay avatar Apr 16 '19 23:04 dtolnay

I would even like to get a slice of all the field names of the struct, including the skipped ones. Data formats which can reuse struct layouts would profit from this as using #[serde(skip_serializing_if = "Option::is_none")] or the equivalent #[skip_serializing_none] from serde_with breaks this. Source: I am currently trying to implement struct layout reusage for my data format and as long as serde isn't telling me about the whole struct layout, I'd have to forbid the aforementioned, really useful features.

yasammez avatar Feb 17 '22 08:02 yasammez