20 cards · Public · Shuffle

Rust Systems Programming - Ownership, Lifetimes & Borrowing

Master memory safety without a garbage collector, strict borrowing rules, lifetimes, smart pointers, and concurrency in Rust with these high-yield flashcards.

Cards in this deck

(20 cards)

Preview terms and definitions before starting your study session.

#1
Term
Three Fundamental Rules of Ownership
Definition
1. Each value in Rust has an owner (a variable).
2. There can only be one owner at a time.
3. When the owner goes out of scope, the value is dropped (freed).
#2
Term
Move Semantics vs. Copy Semantics
Definition
Types implementing the Copy trait perform bitwise duplication on assignment. Types without Copy (e.g., String, Vec) transfer ownership via a move, rendering the original variable uninitialized and unusable.
#3
Term
The Borrow Checker
Definition
A static analysis tool within the Rust compiler that enforces borrowing rules, preventing memory safety bugs such as dangling pointers, double frees, and data races at compile time.
#4
Term
Aliasing XOR Mutability Rule
Definition
At any given point in a scope, you can have either:
  • Any number of immutable references (&T), OR
  • Exactly one mutable reference (&mut T).
You can never have both simultaneously.
#5
Term
Non-Lexical Lifetimes (NLL)
Definition
A compiler feature that determines reference lifetimes based on actual usage in the control flow graph, rather than strict lexical block scopes ({}), making borrowing more flexible.
#6
Term
Lifetime Annotations ('a)
Definition
Explicit syntax (e.g., fn foo<'a>(x: &'a str) -> &'a str) used to tell the compiler how the lifetimes of different references relate to each other, ensuring return references remain valid.
#7
Term
Lifetime Elision Rules
Definition
Three deterministic heuristics compiler rules that allow developers to omit explicit lifetime annotations in common function signature patterns:
1. Each elided input parameter gets its own lifetime.
2. If there is one input lifetime, it is assigned to all output lifetimes.
3. If &self or &mut self is an input, its lifetime is assigned to all output lifetimes.
#8
Term
The Static Lifetime ('static)
Definition
A special lifetime indicating that data lives for the entire execution of the program (e.g., string literals &'static str), or a trait bound specifying a type contains no non-static references.
Showing 8 of 20 cards in this deck.
Study All Now