Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Book: Be very explicit of lifetimes being descriptive #36997

Merged
merged 5 commits into from
Oct 12, 2016
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/doc/book/lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 lifetime annotations are _descriptive_ not _prescriptive_. This means that the lifetimes of references are determined by the code, not by the annotations. The annotations, however, point out the lifetimes to the compiler in case it can't figure them out by itself.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better, but I also think the phrase "the lifetimes of references" should also avoid the overloaded term "lifetime" (just as it says "the annotations" a bit later). This paragraph is clarifying a confusion between the two meanings of the word lifetime (one I've see a lot) so it should avoid anything which could be misinterpreted through the lens of that confusion. Perhaps something along the lines of "how long references are valid is determined by [...]".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave it another shot, thanks for looking at it.


When we have a function that takes an argument by reference, we can be
implicit or explicit about the lifetime of the reference:

Expand Down