What Lifetimes Are (and Are Not)
What Lifetimes Are (and Are Not)
Every reference in Rust has a lifetime—the scope for which that reference is valid.
What Lifetimes Are Not
- Lifetimes do not change how long a value lives at runtime.
- Lifetimes do not allocate or free memory.
- Lifetimes are purely compile-time annotations that help the borrow checker ensure references never outlive the data they point to.