Skip to content

Proposal: Non-exhaustive tagged unions #8162

Open
@tadeokondrak

Description

@tadeokondrak

Currently, tagged unions with a non-exhaustive enum tag don't have the forwards-compatibility features in switches, because it's impossible to create a non-existent union value.

From the non-exhaustive enums proposal:

A non-exhaustive enum is an enum that may have other unknown members.
This can help create APIs that may be extended in future. This sort of thing frequently comes up in data formats, network protocols, and even C APIs.

Non-exhaustive tagged unions can be useful in pure Zig APIs where new variants can be added, but breaking user code on updates is undesirable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions