Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

lifetime parameter

A name like 'a in a signature that links how long references must stay valid.

A lifetime parameter ('a) is a generic parameter over regions; annotations relate the regions of inputs and outputs and are checked, never used to extend anything.

Loading interactive…

Examples

  • fn longest<'a>(a: &'a str, b: &'a str) -> &'a str promises the result is valid only while both inputs are, so it can't be used after either owner is gone.

Read the full section →