02 · Variables and Types
Sigil bindings are immutable by default; let mut opts into mutability. Every binding has an explicit type annotation or one that the compiler infers — there is no var or auto that hides the type. The four primitive scalar types are i32, f32, bool, and str.
fn main() !io { let x: i32 = 42; let y: f32 = 3.14; let flag: bool = true; let name: str = "Sigil";
// Mutable binding — must be declared up front. let mut count: i32 = 0; count += 1;
println!("x = {}", x); println!("y = {}", y); println!("flag = {}", flag); println!("name = {}", name); println!("count = {}", count);}Output
Section titled “Output”x = 42y = 3.14flag = truename = Sigilcount = 1What the compiler sees
Section titled “What the compiler sees”Attempting to reassign an immutable binding is a compile error, not a runtime panic. The compiler also tracks whether a mut binding is actually mutated — unused mutability is a warning. Type annotations can be omitted when the initializer makes the type unambiguous (e.g., let x = 42; infers i32).
Next → 03 · Functions