20 cards · Public · Shuffle

Rust Systems Programming - Ownership, Borrowing & Concurrency

Master Rust's zero-cost abstractions, lifetime semantics, memory safety guarantees, and fearless concurrency models with this high-yield flashcard deck.

Cards in this deck

(20 cards)

Preview terms and definitions before starting your study session.

#1
Term
What are the three fundamental rules of Ownership in Rust?
Definition
1. Each value in Rust has an owner variable.
2. There can only be one owner at a time.
3. When the owner goes out of scope, the value is automatically dropped.
#2
Term
How do move semantics work when assigning non-Copy types?
Definition
Assigning a non-Copy variable to another transfers ownership (a move). The source variable becomes uninitialized and invalid, preventing double-free bugs at compile time without needing a garbage collector.
#3
Term
What is the key difference between the Copy and Clone traits?
Definition
  • Copy: Implicit, cheap bitwise duplicate performed by the compiler (e.g., stack-only types like i32, f64, tuples of Copy types).
  • Clone: Explicit method call (.clone()) that can perform expensive deep memory allocations (e.g., heap-allocating types like String or Vec<T>).
#4
Term
What is Borrowing, and what are its two core reference rules?
Definition
Borrowing grants temporary access to data without taking ownership.
Rules:
1. At any given time, you can have any number of immutable references (&T) OR exactly one mutable reference (&mut T).
2. References must always be valid (dangling references are caught at compile time).
#5
Term
Why does Rust enforce the 'Aliasing XOR Mutability' principle?
Definition
Allowing multiple active references where at least one can mutate data leads to data races, iterator invalidation, and memory corruption. Rust prevents this at compile time by ensuring mutability is strictly exclusive.
#6
Term
What are Non-Lexical Lifetimes (NLL)?
Definition
NLL is a borrow checker capability where a reference's lifetime ends at its last point of use, rather than stretching to the end of its enclosing scope block. This removes many false-positive borrow errors.
#7
Term
What is the purpose of explicit lifetime annotations like 'a in function signatures?
Definition
Lifetime annotations describe the relationships between references' lifetimes across parameters and return values. They do not alter actual run-time lifespans; they assist the compiler in verifying that returned references remain valid.
#8
Term
What are the three Lifetime Elision Rules used by the compiler?
Definition
1. Each elided reference parameter gets a distinct input lifetime annotation.
2. If there is exactly one input lifetime, it is assigned to all output lifetimes.
3. If an input parameter is &self or &mut self, its lifetime is assigned to all output lifetimes.
Showing 8 of 20 cards in this deck.
Study All Now