Skip to content

Commit

Permalink
Ownership controls lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Jan 23, 2025
1 parent 1fd48d6 commit 96c8e13
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lifetimes/lifetime-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ also be explicit: `&'a Point`, `&'document str`. Lifetimes start with `'` and
`'a` is a typical default name. Read `&'a Point` as "a borrowed `Point` which is
valid for at least the lifetime `a`".

Only ownership, not lifetime annotations, control when objects are destroyed and
determine the concrete lifetime of a given value. The borrow checker just
ensures this is done safely.

Explicit lifetime annotations, like types, are required on function signatures
(but can be elided in common cases). These provide information for inference at
callsites and within the function body.
callsites and within the function body, helping the borrow checker to do its
job.

<!-- The multi-line formatting by rustfmt in left_most is apparently
intentional: https://github.com/rust-lang/rustfmt/issues/1908 -->
Expand Down

0 comments on commit 96c8e13

Please sign in to comment.