Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Construction

The construction postfix operation constructs a new value of a structure or enumeration type from its arguments.

Process

At runtime:

  1. the arguments are evaluated, left to right; and
  2. a value of the operand's structure type, or of the enumeration type of the referenced enumeration variant, is constructed from them.

Assertions

  1. The operand is either:
  2. Structure construction arguments are positional: there is exactly one argument per declared field, in declared order.
  3. An enumeration construction has exactly one argument, the referenced variant's declared payload value; a variant with no declared payload has zero arguments.
  4. Each argument has the type of its corresponding field or payload, and its expected type is that type.

Syntax

construction_operation = left_brace, [ expression, { comma, expression } ], right_brace ;