Zero-sized type

A type that occupies no memory and is optimized away by the compiler. For example, a  never allocates memory. It is usually abbreviated ZST.

Zero-sized types are:

 The empty tuple  The never type  Structs, unions and tuples, if all their fields are zero-sized, e.g.

 Enums with at most one variant that isn't uninhabited, if all its fields are zero-sized, e.g.

 

Note that is also a ZST. It is a special type, because it is generic, even though it has no fields.

Note that and  are not zero-sized. Rust doesn't treat them as uninhabited types, even though they have no possible values.

N-ZSTs
One important aspect of memory layout of a type is its alignment. To distinguish ZSTs with different alignments, Rust developers agreed to call them n-ZSTs in natural language and there is a proposal to use,  ,  ,  ,  ,  ,  , and   as identifiers in programs.