The borrowing track ended with a promise: the compiler tracks how long each reference is valid, and that tracking is called lifetimes. This track demystifies the scariest-looking syntax in Rust — and shows you it's mostly invisible.
Lifetimes are not durations
First, kill the wrong intuition: a lifetime is not 'how many milliseconds the value lives.' It's a compile-time region of code over which a reference is valid. The compiler reasons about these regions to guarantee no reference ever points at dropped data. You're not timing anything; you're describing relationships between scopes.
Most lifetimes are inferred
Here's the relief: the vast majority of the time you write zero lifetime annotations. You've already written functions taking references without a single 'a in sight. Annotations only appear when the compiler genuinely can't figure out a relationship on its own.
'a don't change how long anything lives — they describe which references must stay valid as long as which others. You're giving the compiler a fact it couldn't infer, nothing more.When you must annotate
The classic case: a function takes two references and returns one. Which input does the output borrow from? The compiler can't always tell, so it asks you to say. That single scenario is where most lifetime syntax comes from — and it's the focus of the next two lessons.