mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-12-04 03:25:08 +02:00
Make instructions in lifetimes-function-calls.md more precise
This commit is contained in:
parent
597c875442
commit
512dedf729
@ -28,7 +28,7 @@ fn main() {
|
||||
|
||||
In the above example, try the following:
|
||||
|
||||
* Move the declaration of `p2` and `p3` into a a new scope (`{ ... }`). You have to declare `p3` as `let p3: &Point;`, in `main`'s scope before that new block. Note how this does not compile since `p3` outlives `p2`.
|
||||
* Move the declaration of `p2` and `p3` into a a new scope (`{ ... }`). You have to declare `p3` as `let p3: &Point;`, in `main`'s scope before that new block, and in the block assign to `p3` without the `let` (just `p3 = left_most(...)`). Note how this does not compile since `p3` outlives `p2`.
|
||||
* Reset the workspace and change the function signature to `fn left_most<'a, 'b>(p1: &'a Point, p2: &'a Point) -> &'b Point`. This will not compile because the relationship between the lifetimes `'a` and `'b` is unclear.
|
||||
|
||||
</details>
|
||||
|
Loading…
Reference in New Issue
Block a user