sway_ir

Module irtype

Source
Expand description

Each of the valid Value types.

These generally mimic the Sway types with a couple of exceptions:

  • [Type::Unit] is still a discrete type rather than an empty tuple. This may change in the future.
  • [Type::Union] is a sum type which resembles a C union. Each member of the union uses the same storage and the size of the union is the size of the largest member.

[Aggregate] is an abstract collection of Types used for structs, unions and arrays, though see below for future improvements around splitting arrays into a different construct.

Structs§

  • Provides information about a size of a type, raw and aligned to word boundaries.

Enums§

  • Provides information about padding expected when laying values in memory. Padding depends on the type of the value, but also on the embedding of the value in aggregates. E.g., in an array of u8, each u8 is “padded” to its size of one byte while as a struct field, it will be right padded to 8 bytes.

Traits§

  • A helper to check if an Option value is of a particular Type.