The Lifetime Elision Rules

Updated

October 31, 2026

The Lifetime Elision Rules

In common function patterns, Rust automatically infers lifetime parameters via three elision rules:

  1. Each parameter that is a reference gets its own lifetime parameter (fn foo<'a, 'b>(x: &'a i32, y: &'b i32)).
  2. If there is exactly one input lifetime parameter, that lifetime is assigned to all output lifetime parameters (fn foo<'a>(x: &'a i32) -> &'a i32).
  3. If there are multiple input lifetime parameters, but one of them is &self or &mut self, the lifetime of self is assigned to all output lifetime parameters.