| Section | Title |
|---|---|
| 1 | Struct Definitions |
| 2 | Struct Methods |
| 3 | Default Field Values |
| 4 | Packed Structs |
| 5 | Anonymous Structs |
| 6 | Enums |
| 7 | Tagged Unions |
| 8 | Union Safety |
| 9 | Modeling State Machines |
| 10 | Data-Oriented Design |
Struct DefinitionsA struct is a type that groups several values together.
Struct MethodsA struct method is a function that belongs to a struct.
Default Field ValuesA struct field can have a default value.
Packed StructsA normal Zig struct is designed for ordinary data modeling.
Anonymous StructsAn anonymous struct is a struct type without a name.
EnumsAn enum is a type whose value must be one item from a fixed list.
Tagged UnionsA tagged union is a type that can store one value from several possible shapes.
Union SafetyA union stores one active field at a time.
Modeling State MachinesA state machine is a simple way to describe a program that moves between fixed states.
Data-Oriented DesignData-oriented design means you organize a program around the data it processes.