#i32 int_ptr; // immutable pointer to i32##i32 ptr_to_ptr; // immutable pointer to immutable pointer to i32~#i32 mut_ptr_to_ptr; // mutable pointer to immutable pointer to i32#~i32 ptr_to_mut_ptr; // immutable pointer to mutable pointer to i32// Ownership and borrowing#Matrix m := create_matrix(); // owned value#Matrix borrowed_m #= m; // immutable borrow~Matrix mutable_m #= m; // mutable borrow
union Number = i32|f64;union FileErrors = AccessDenied|FileNotFound;
Type Conversion Rules
Implicit Promotions
// Implicit promotionsi32 x = 42;i34 y = x; // widening of same numeric classf32 z = x;f64 bigz = x; // int-to-float + wideningu32 a = 96;u64 b = a; // widening of same numeric classf64 c = a; // int-to-float + wideningf128 d = c; // widening of same numeric class
Explicit Conversions
// Explicit conversions for narrowingf64 pi = 3.14159;i32 truncated = trunc(pi); // use rounding functions// Bit reinterpretationu32 bits = 0x3F800000;f32 float_val = bits as f32;// Context-driven literal typingu8 small = 255; // 255 becomes u8i16 medium = 255; // 255 becomes i16