Types and Values
Primitive types, compound values, inference, unions, absence, and casts.
Primitive types
The primitive set is intentionally broad enough for systems code and small enough to stay readable.
- Integers exist at fixed widths, plus
isizeandusizefor pointer-sized values. f32andf64cover floating-point math.char,str,bool,nil,(), and!fill out the basic value model.
Compound types
Tuples, arrays, slices, lists, maps, and sets each represent a different storage and ownership story.
[T; N]is a fixed-size array.&[T]is a borrowed slice.List<T>owns a growable heap buffer.Map<K, V>andSet<T>are heap-managed collections with their own mutation APIs.
Absence
La3 keeps one absence value and gives it two useful presentations.
nil is the runtime value. Option<T> is the explicit enum wrapper. The two map to the same underlying absence case so the reader can choose the lighter or louder spelling depending on context.
T | nilis the lightweight form for local flow.Option<T>is the explicit form for signatures and APIs.??,?.,map,unwrap_or, and?cover the common control patterns.
let host = lookup(name) ?? "localhost"
let first: Option<str> = items.first()Inference and casts
Type inference removes noise, but it never hides a real conversion.
- A binding without annotation takes the initializer type.
- Unsuffixed integers default to
i32; unsuffixed floats default tof64. - There is no implicit numeric widening or narrowing.
asmarks the exact place where a conversion occurs.