Uh oh!
There was an error while loading. Please reload this page.
Explain motivation behind lifetimes - #36755
Conversation
rust-highfive
commented
Sep 26, 2016
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Just write let r; here. Initializing it to &0 and then re-assigning it later triggers another error because you didn't declare r mutable, which is irrelevant to the point about lifetimes.
There was a problem hiding this comment.
minor style nit: <'a, 'b> with space
Eh2406
commented
Sep 26, 2016
"less than a week" and already helping with the docs! Thank you! |
durka
commented
Sep 26, 2016
Travis says: You'll need to put "```rust,no_run" at the top of your examples when you know they won't compile. Or possibly there is a way nowadays to annotate them with the expected error, cc @GuillaumeGomez ? |
Rantanen
commented
Sep 27, 2016
Took care of those issues hopefully.
Unfortunately I can't test the last one locally as the local Rust installation is interfering with the |
GuillaumeGomez
commented
Sep 27, 2016
@durka: There is. If you expect an error, you have to add "compile_fail" and the expected error code (this second part isn't mandatory but it's better to have it). So for example: |
steveklabnik
left a comment
There was a problem hiding this comment.
Thank you for this! This is good overall, but some small nits.
There was a problem hiding this comment.
Teaching advice: I would stay away from "simple". Say something like "In a small case like this" or just "in a case like this."
The reason is, it might be simple to you, but not to your reader. If they hear you say "this is simple" and then they look at it and go "I have no idea what's going on", they get the impression that the topic isn't for them, and bail.
This applies almost universally in teaching, but especially in the chapter on the most complex topic in Rust 😄
There was a problem hiding this comment.
we use + rather than o elsehwere in this chapter for this
Rantanen
commented
Sep 27, 2016
Changed to use |
Rantanen
commented
Sep 27, 2016
There seems to be some inconsistencies concerning the Which one is the preferred style for the examples? Without explicit |
steveklabnik
commented
Sep 27, 2016
In general, without explicit main is considered best. Sometimes, you have to have it though. But 99% of the time, you don't. |
bors
commented
Oct 12, 2016
☔ The latest upstream changes (presumably #37090) made this pull request unmergeable. Please resolve the merge conflicts. |
Rantanen
commented
Oct 12, 2016
Didn't see guidelines for resolving the merge conflicts. I went with merging master to the PR. Is this okay, or would a rebase on top of the new master have been preferred? Also curious on whether I should keep maintaining the PR. I'm guessing most of the documentation resources are going into rust-lang/book currently. If I should keep maintaining it, is there any status information? (Mainly I'm curious on whether this PR is in some kind of a limbo due to open change requests. Is there a way to mark those as "done". Couldn't find any documentation in the GitHub review article.) |
steveklabnik
commented
Oct 12, 2016
A rebase on top of the new master is better, actually.
Yes please! That book is still months out from launching, this helps everyone in the meantime. And since my focus is on that, it's extra valuable to have people help out here.
There's two reasons:
So first, let's fix that: @bors: r? @steveklabnik Second, I let me review this again, and then you can do the rebase and/or take care of any other nits, and then we can merge this. So sorry again. |
steveklabnik
commented
Oct 12, 2016
Yes, this looks great. If you can do that rebase, I can get this merged. Sorry again. |
Start the lifetime section with an explanation of the issues that lack of explicit lifetimes cause and how lifetimes alleviate these.
Rantanen
commented
Oct 12, 2016
No problem! Was partly my fault to begin with as I didn't request you to review the code like suggested in the contribution guidelines. Rebase done. |
GuillaumeGomez
commented
Oct 13, 2016
Thanks! @bors: r+ rollup |
bors
commented
Oct 13, 2016
📌 Commit cb90723 has been approved by |
bors
commented
Oct 13, 2016
⌛ Testing commit cb90723 with merge 9cb498d... |
bors
commented
Oct 13, 2016
💔 Test failed - auto-linux-cross-opt |
Rantanen
commented
Oct 13, 2016
Seems like the auto-linux-cross-opt build was broken last night (UTC anyway) so I'm assuming there's nothing for me to do to get that resolved. |
durka
commented
Oct 13, 2016
That's the same bogus failure from #37119. On Thu, Oct 13, 2016 at 11:47 AM, Mikko Rantanen notifications@github.com
|
arielb1
commented
Oct 13, 2016
@bors retry |
alexcrichton
commented
Oct 13, 2016
@bors: retry |
Explain motivation behind lifetimes Start the lifetime section with an explanation of the issues that lack of explicit lifetimes cause and how the explicit lifetimes solve these. ---------------- I had really hard time figuring out why I would need to care about the explicit reference lifetimes when going through the book at first. With strong background in C++, I'm familiar with the dangling reference problem - but given the section seems to focus more on the lifetime syntax and various ways to define lifetimes on functions and structs, I was unable to understand how they are used to solve the reference problem. This PR is an attempt at getting the reader to understand what the explicit lifetimes are used for and why they are an awesome thing instead of a bit of syntax that just has to be written. It's been less than a week that I've been diving into Rust so I'm far from certain about the terminology and technical correctness. I tried mimicking the existing terminology from the lifetimes section, but still no promises on getting it right.
Start the lifetime section with an explanation of the issues that lack of explicit lifetimes cause and how the explicit lifetimes solve these.
I had really hard time figuring out why I would need to care about the explicit reference lifetimes when going through the book at first. With strong background in C++, I'm familiar with the dangling reference problem - but given the section seems to focus more on the lifetime syntax and various ways to define lifetimes on functions and structs, I was unable to understand how they are used to solve the reference problem.
This PR is an attempt at getting the reader to understand what the explicit lifetimes are used for and why they are an awesome thing instead of a bit of syntax that just has to be written.
It's been less than a week that I've been diving into Rust so I'm far from certain about the terminology and technical correctness. I tried mimicking the existing terminology from the lifetimes section, but still no promises on getting it right.