Skip to content

Basics & Syntax

Rust is a systems programming language designed around three goals:

  1. Memory safety — the compiler guarantees freedom from null-pointer dereferences, use-after-free bugs, and data races, entirely at compile time.
  2. Performance — Rust compiles to native machine code with no runtime overhead. There is no garbage collector, no virtual machine, no interpreter.
  3. Fearless concurrency — the same ownership rules that prevent memory bugs also prevent data races across threads.

The key insight is that Rust achieves these guarantees through the borrow checker — a piece of the compiler that enforces ownership and lifetime rules before your program ever runs. If it compiles, it is memory-safe.

LessonConcept
Variables & Mutabilitylet, mut, shadowing, const
Data TypesScalars, tuples, arrays, type inference
Functionsfn, parameters, return types, expressions vs statements
Control Flowif as an expression, loop, while, for, ranges

Every Rust binary starts from fn main(). The println! macro writes formatted text to standard output. Types are inferred by the compiler when they are unambiguous — you do not need to annotate every variable.

fn main() {
println!("Rust guarantees memory safety at compile time.");
println!("No garbage collector. No null pointer exceptions.");
println!("Zero-cost abstractions. Systems-level performance.");
let x: i32 = 42;
let name = "Rust";
println!("x = {}, name = {}", x, name);
}

The {} in format strings are placeholders — the macro substitutes the corresponding argument value at runtime.

fn main() {
println!("Rust guarantees memory safety at compile time.");
println!("No garbage collector. No null pointer exceptions.");
println!("Zero-cost abstractions. Systems-level performance.");
let x: i32 = 42;
let name = "Rust";
println!("x = {}, name = {}", x, name);
}
How does Rust guarantee memory safety?
What is the entry point of every Rust binary?
What does the {} placeholder do inside a println! format string?