Type rules
This topic is not available in the selected language or version. Showing the start of this section.
Built-in types
Section titled “Built-in types”Int = I64; Float = F64. Integers are I8, I16, I32, I64, U8, U16, U32, and U64. Floating types are F32 and F64. Bool is true or false; Unit has the value (). Strings contain bytes.
Conversions and ranges
Section titled “Conversions and ranges”Numeric types do not mix implicitly. Convert explicitly, for example with i32(value). Out-of-range conversions fail. Integer +, -, and * wrap. Division by zero and division of the minimum signed value by -1 are runtime errors.
Composite types
Section titled “Composite types”Use Vec<T>, structs, enums, and tuples. Declare methods in impl blocks. Generic functions and types are supported; supply all type arguments when inference is insufficient. Recursive data requires a Box or Vec boundary. Struct and enum == is unavailable.
Learn more: Variables and values · Structs and enums · Generics and type inference
Worked examples: Data types and conversions · Box and recursive data