Concept Flow - Lifetime elision rules
Start: Function with references
Check input lifetimes
Apply Rule 1: One input ref?
| Yes
Output lifetime = input lifetime
No
Apply Rule 2: Multiple input refs, one &self or &mut self?
| Yes
Output lifetime = self's lifetime
No
Apply Rule 3: Multiple input refs, no self
Output lifetime = anonymous, compiler error if ambiguous
End
The compiler applies three rules to assign lifetimes to references in functions without explicit annotations, simplifying code while ensuring safety.