From 213063730183648cd84767f30503eb1697c6344b Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Thu, 6 Oct 2016 10:47:55 +0200 Subject: [PATCH] Book: Be very explicit of lifetimes being descriptive ... no prescriptive. Pointed out in https://users.rust-lang.org/t/what-if-i-get-lifetimes-wrong/7535/4, which was a revelation to me and made me think this should be more clear in the book. --- src/doc/book/lifetimes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/doc/book/lifetimes.md b/src/doc/book/lifetimes.md index f7d9c94bc454..9918c24e1758 100644 --- a/src/doc/book/lifetimes.md +++ b/src/doc/book/lifetimes.md @@ -56,6 +56,8 @@ To fix this, we have to make sure that step four never happens after step three. The ownership system in Rust does this through a concept called lifetimes, which describe the scope that a reference is valid for. +*Note* It's important to understand that lifetimes are _descriptive_ not _prescriptive_. This means that the lifetimes of references are determined by the code, not by the lifetime annotations. The annotations, however, point out the lifetimes to the compiler in case it can't figure them out by itself. + When we have a function that takes an argument by reference, we can be implicit or explicit about the lifetime of the reference: