Types
Types
This chapter describes the type system of Rue.
Every value in Rue has a type that determines its representation in memory and the operations that can be performed on it.
Zero-Sized Types
A zero-sized type (ZST) is a type with a size of zero bytes. Zero-sized types can be instantiated and passed by value, but they occupy no storage.
The following types are zero-sized:
- The unit type
() - The never type
! - Empty structs (structs with no fields)
- Zero-length arrays
[T; 0]for any typeT
Zero-sized types have an alignment of 1 byte.
Recursive Value Types
A struct or enum MUST NOT contain itself by value, either directly or through a cycle of struct fields, enum payloads, or array elements. A non-zero by-value cycle has no finite size. A raw-pointer edge does not contain its pointee by value and therefore breaks the cycle. For uniform structural well-formedness, array edges remain recursive-type edges even when their length is zero. A recursive by-value cycle is a compile-time error (E0483).