LogoMist

Variables

Variable declarations, mutability, type annotations, and destructuring.

let x = 42;                         // Type-inferred immutable
let mut y = 10;                     // Mutable variable
i32 z = 100;                        // Explicit type annotation
str& s = "hello";                   // Typed string reference
bool b = true;                      // Typed boolean
f64 f = 3.14;                       // Typed float
(i32, str&) as x, y = (1, "hello"); // Typed tuple destructuring
let (a, b) = (1, "two");            // Destructuring
let (x, (y, z)) = (1, (2, 3));      // Nested destructuring

Variable declarations follow either of two forms:

let <pattern> [= <expr>];
<type> <pattern> [= <expr>];

Tuple Variable Declarations

Tuple variables can be declared with explicit type annotations using as:

(i32, bool) as x, y = (1, true);

i32 a, b = (1, 2, 3);

Const and Static

const MAX: i32 = 100;
static NAME: str& = "hello";

On this page