Enumeration Type
Like all type expressions, this expression produces a value of the type type.
Enumeration-typed values are one of a finite set of variants determined by the specific enumeration type. A variant may carry a payload value.
Each enumeration declaration introduces a new enumeration type. Each variant declared by an enumeration is a compile-time entity of that enumeration's type: a variant cannot be evaluated as a runtime value, and may only be used to construct a value or as a match pattern.
Assertions
- An enumeration declares at most 256 variants.
Representation
Values of an enumeration type are represented as:
- a
u8tag distinguishing the variant; and - a union of the possible payloads for the specific enumeration type.
Lookup Scope
Each enumeration type's variants are resolved as members of the enumeration type value itself: the static access operation on a value of the type type which denotes an enumeration type resolves its provided identifier to that enumeration's variant of the same name.
Syntax
Produced by the reference expression when the referenced symbol is an enumeration type.