about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-10-11 17:51:26 +0200
committerGitHub <noreply@github.com>2016-10-11 17:51:26 +0200
commit97e9eac8bf3b791cdc3cd0a97fa17a802286373f (patch)
tree29fccfd6102e67d4db1600b4bc41c55c0e8c5cd6 /src
parent0b7fe4d67cc4d3b09bea212a9a94d41b36d5d50c (diff)
parent0d0cdb77dfe5efc9ded30e6ab8b175d602b07223 (diff)
downloadrust-97e9eac8bf3b791cdc3cd0a97fa17a802286373f.tar.gz
rust-97e9eac8bf3b791cdc3cd0a97fa17a802286373f.zip
Rollup merge of #36997 - KillTheMule:patch-1, r=steveklabnik
Book: Be very explicit of lifetimes being descriptive

... not 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. I'm not sure if I got this entirely right or if the wording is good, but I figured a PR is more helpful than a simple issue.

r? @steveklabnik

Small Note: There's also https://github.com/rust-lang/book, should I have sent the PR there? It doesn't coincide with the online book though, so I figured it's better of here.
Diffstat (limited to 'src')
-rw-r--r--src/doc/book/lifetimes.md8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/doc/book/lifetimes.md b/src/doc/book/lifetimes.md
index f7d9c94bc45..e865609f217 100644
--- a/src/doc/book/lifetimes.md
+++ b/src/doc/book/lifetimes.md
@@ -56,8 +56,12 @@ 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.
 
-When we have a function that takes an argument by reference, we can be
-implicit or explicit about the lifetime of the reference:
+**Note** It's important to understand that lifetime annotations are
+_descriptive_, not _prescriptive_. This means that how long a reference is valid
+is determined by the code, not by the annotations. The annotations, however,
+give information about lifetimes to the compiler that uses them to check the
+validity of references. The compiler can do so without annotations in simple
+cases, but needs the programmers support in complex scenarios.
 
 ```rust
 // implicit