Loading RustViz Engine...
Visualize lifetime relationships ('a), the 3 lifetime elision rules, and subtyping variance rules (Covariance vs Invariance).
Analyze lifespan overlap constraints and verify when a reference outlives its source data.
1fn main() {2 let outer_string = String::from("Safe & Sound"); // Lifetime 'a3 let r: &str;4 {5 r = &outer_string; // Reference lives in 'b, data lives in 'a6 println!("Inner read: {}", r);7 }8 println!("Outer read: {}", outer_string);9}
Each elided lifetime in function arguments is assigned its own distinct lifetime parameter.
If there is exactly one input lifetime, that lifetime is assigned to all output references.
If there are multiple input parameters and one is &self, the lifetime of self is assigned to all outputs.