Skip to content

add optional support #2

@jackdotink

Description

@jackdotink

We can be pretty smart around this implementation by optimizing for locations where marker values can be used to represent an optional value. The simplest example is an out of bounds number: if the serialized value for zap.optional(zap.u8(1, 50)) is 0 that can mark the value as nil without needing a boolean flag to be sent.

This optimization can and should apply in other less trivial places, such as encoding 0 in an optional array, set, or map length to mean nil, and for all other values subtracting 1 get the actual length.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions