Rust glossary – key terms explained
Borrow checker
The part of the compiler that verifies that references are valid and that the rules (many & or one &mut) are followed.
Borrowing
Lending out a value by reference (&T or &mut T) without taking ownership.
Cargo
Build system and package manager: builds, tests, and manages dependencies (Cargo.toml).
Copy / Clone
Copy: cheap, implicit copying (numbers). Clone: explicit .clone(), possibly with a deep copy.
Crate
Compilation unit in Rust: a library or a program. Packages come from crates.io.
Lifetime
The scope in which a reference is valid. Annotations like 'a describe relationships between references.
Macro
Code that generates code, recognizable by the ! (e.g. println!, vec!); expanded at compile time.
Monomorphization
The compiler generates a separate version of generic code for each concrete type used, with no runtime cost.
Move
Transfer of ownership on assignment or function call; the old variable is invalid afterwards.
Option
Enum Some(T) / None; replaces null and forces you to handle the empty case.
Ownership
Rust's memory model: every value has exactly one owner; when the owner goes out of scope, the value is freed.
Pattern matching
Taking apart and comparing values with match, if let, or let; must be exhaustive.
Result
Enum Ok(T) / Err(E) for operations that can fail; replaces exceptions.
Send / Sync
Marker traits for thread safety: Send = ownership may move to other threads, Sync = &T may be shared.
Shadowing
Redeclaring a variable with let and the same name; the old one is hidden afterwards (even with a different type).
Slice
A view of a contiguous part of a collection (&[T], &str), without ownership.
Smart pointer
A pointer type with additional behavior such as Box, Rc, Arc, or RefCell; implements Deref and often Drop.
Trait
Describes shared behavior (methods) that types implement; Rust's tool for polymorphism.
unsafe
A block in which some compiler checks are suspended (e.g. raw pointers); the programmer guarantees correctness.
Zero-cost abstraction
Abstractions (iterators, generics) that are as fast as hand-written code after compilation.