Rust Notes — Module 1
Rust Notes — Module 1: The Basics & Ownership 1. Why Rust? Language Memory Management Cost C Manual (malloc/free) Unsafe — use-after-free, double-free, null deref Go Garbage Collector Safe, but runtime overhead (GC pauses) Rust Ownership system (compiler-enforced) Safe + zero runtime cost Rust’s core promise: memory safety at compile time, with no garbage collector. 2. Variables & Mutability Variables are immutable by default in Rust. You must explicitly opt into mutation with mut. let x = 5; // immutable — cannot be reassigned // x = 6; // ❌ compile error let mut y = 5; // mutable y = 6; // ✅ fine Shadowing You can redeclare a variable with let in the same scope — this is called shadowing: ...