]> git.proxmox.com Git - rustc.git/blame - src/doc/reference/src/types/enum.md
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / doc / reference / src / types / enum.md
CommitLineData
13cf67c4
XL
1# Enumerated types
2
3An *enumerated type* is a nominal, heterogeneous disjoint union type, denoted
4by the name of an [`enum` item]. [^enumtype]
5
6An [`enum` item] declares both the type and a number of *variants*, each of
7which is independently named and has the syntax of a struct, tuple struct or
8unit-like struct.
9
6a06907d 10New instances of an `enum` can be constructed with a [struct expression].
13cf67c4
XL
11
12Any `enum` value consumes as much memory as the largest variant for its
13corresponding `enum` type, as well as the size needed to store a discriminant.
14
15Enum types cannot be denoted *structurally* as types, but must be denoted by
16named reference to an [`enum` item].
17
5869c6ff 18[^enumtype]: The `enum` type is analogous to a `data` constructor declaration in
13cf67c4
XL
19 ML, or a *pick ADT* in Limbo.
20
416331ca 21[`enum` item]: ../items/enumerations.md
6a06907d 22[struct expression]: ../expressions/struct-expr.md