Stage 1 · Lesson 3 of 10
Ownership, borrowing and lifetimes
is what makes Rust different, so give it real time. Every value has exactly one owner, and the value is freed when its owner goes out of scope. Assigning a String to another variable moves it, and the old name can no longer be used.
To use a value without taking it, you borrow it with a reference. You can have many shared references (&T) or one mutable reference (&mut T), but never both at once. The , part of the compiler, enforces these rules.
That is how Rust prevents use-after-free bugs and data races without a garbage collector. Lifetimes are how the compiler proves a reference never outlives the value it points to.
Common trapcalling .clone() on everything to make the errors go away, which hides the real question the compiler is asking: who owns this data?
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- BookFreeThe Rust Programming Language
The Rust Project · Beginner
The official book, free online: read ownership, enums, error handling and traits slowly
- GuideFreeTokio Tutorial
Tokio · Intermediate
The official Tokio tutorial: tasks, shared state, channels and the async model Axum runs on
Practise
Keep handy
Also worth your time
The DNS, TCP, TLS and HTTP steps behind every request your backend will handle