Skip to main content

Memory Model for Rusts

The Rust memory model is the set of rules, ownership, borrowing and lifetimes, that lets the compiler manage memory without a garbage collector. Each value has one owner, assigning or passing it moves ownership, references borrow it temporarily, and lifetimes tell the compiler how long a reference stays valid.

Stage: Ownership · Part of the Rust roadmap · Last reviewed 19 November 2026

What to learn in Memory Model

Memory Model interview questions

What are Rust's borrowing rules?

At any time you may have either any number of shared references or exactly one mutable reference to a value, and references must not outlive the data they point to. These rules prevent data races and use-after-free errors, and the compiler enforces them.

What does a lifetime annotation like 'a mean?

It names a region of code for which a reference is valid, so the compiler can relate input and output references. In fn longest<'a>(x: &'a str, y: &'a str) -> &'a str, the result cannot outlive either input. Annotations describe relationships and do not change how long data lives.

Where Memory Model fits in the Rust roadmap

Memory Model belongs to the Ownership stage (intermediate level), which takes about 28 hours. The core idea.

Back to the full Rust roadmap