Rust theorytheory 0/50 · 0%
Ownership · medium

24. Lifetimes

Naming how long references are valid.

Lifetimes are compile-time annotations ensuring a reference never outlives its data. Most are inferred by elision rules; explicit `'a` parameters are needed when a function returns a reference derived from inputs. `'static` means the data lives for the whole program.

Check your understanding

  1. 1. Lifetimes exist at…

  2. 2. What does 'static mean?