Rust Systems & Tokio (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is the `'static` lifetime?
senior LevelSystem Design
In Simple Words:
The 'static lifetime means the data can live for the entire duration of the program:
- String literals (
let s: &'static str = "hello";) are stored directly in the read-only data segment of the compiled binary file. - Owned types (
T: 'static) mean the type does not contain any borrowed references with shorter lifetimes (essential for passing data into multi-threadedthread::spawn).