Python Scalar & Compound Types (Integers, Floats, Tuples, Arrays)
Rust is statically typed with strong type inference. It features scalar types (integers i8-i128, u8-u128, isize/usize, f32/f64, bool, char) and compound types (tuples and fixed-size arrays [T; N]).
"Scalar types are individual Lego bricks (single numbers or letters). Compound types are assembled Lego kits—a tuple is a multi-color assorted kit, and an array is a rigid tray of identical bricks."
Deep Dive: How It Works
Integer Types: i32 is the default integer type. usize matches the target CPU pointer architecture.
Tuples: Group multiple values of different types with fixed arity: let t: (i32, f64, &str) = (1, 2.5, "hi");.
Arrays: Fixed-length lists stored contiguously on the stack: let a: [i32; 3] = [10, 20, 30];.
Syntax Blueprint
let tuple: (i32, bool) = (42, true); let arr: [i32; 3] = [1, 2, 3];
Tuples access elements with .index (tuple.0), while arrays access with [index] (arr[0]).
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Trying to change the length of a Rust array.Why it happens: Standard Rust arrays [T; N] have a fixed size on the stack and cannot grow.
How to fix: If you need a growable dynamically-sized collection, use Vec<T> instead.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Extract tuple and array elements
Declare let config: (&str, u16) = ("localhost", 8080);
Declare let ports: [u16; 2] = [8080, 8443];
Print "Server: localhost on port 8080 | SSL: 8443".
Finished reading and practicing?
Mark this lesson as completed to update your course progress.