From e74d176dca249873330497b2caaec0564463a71f Mon Sep 17 00:00:00 2001 From: Louis Cloete <38226392+L0uisc@users.noreply.github.com> Date: Mon, 8 Apr 2019 17:45:23 +0200 Subject: [PATCH 1/2] Update ch10-03-lifetime-syntax.md --- src/ch10-03-lifetime-syntax.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ch10-03-lifetime-syntax.md b/src/ch10-03-lifetime-syntax.md index c9961bf3ab..3b2cc81d3a 100644 --- a/src/ch10-03-lifetime-syntax.md +++ b/src/ch10-03-lifetime-syntax.md @@ -277,13 +277,15 @@ The function signature now tells Rust that for some lifetime `'a`, the function takes two parameters, both of which are string slices that live at least as long as lifetime `'a`. The function signature also tells Rust that the string slice returned from the function will live at least as long as lifetime `'a`. -These constraints are what we want Rust to enforce. Remember, when we specify -the lifetime parameters in this function signature, we’re not changing the -lifetimes of any values passed in or returned. Rather, we’re specifying that -the borrow checker should reject any values that don’t adhere to these -constraints. Note that the `longest` function doesn’t need to know exactly how -long `x` and `y` will live, only that some scope can be substituted for `'a` -that will satisfy this signature. +In practice, it means that the lifetime of the reference returned by the +`longest` function is the same as the smaller of the lifetimes of the +references passed in. These constraints are what we want Rust to enforce. +Remember, when we specify the lifetime parameters in this function signature, +we’re not changingthe lifetimes of any values passed in or returned. Rather, +we’re specifying that the borrow checker should reject any values that don’t +adhere to these constraints. Note that the `longest` function doesn’t need to +know exactly how long `x` and `y` will live, only that some scope can be +substituted for `'a` that will satisfy this signature. When annotating lifetimes in functions, the annotations go in the function signature, not in the function body. Rust can analyze the code within the From e59c9f8ee9645e39348a3bfcf7f6919a2ef369e0 Mon Sep 17 00:00:00 2001 From: Louis Cloete <38226392+L0uisc@users.noreply.github.com> Date: Mon, 8 Apr 2019 18:11:04 +0200 Subject: [PATCH 2/2] Corrected typo --- src/ch10-03-lifetime-syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch10-03-lifetime-syntax.md b/src/ch10-03-lifetime-syntax.md index 3b2cc81d3a..fffcf738c9 100644 --- a/src/ch10-03-lifetime-syntax.md +++ b/src/ch10-03-lifetime-syntax.md @@ -281,7 +281,7 @@ In practice, it means that the lifetime of the reference returned by the `longest` function is the same as the smaller of the lifetimes of the references passed in. These constraints are what we want Rust to enforce. Remember, when we specify the lifetime parameters in this function signature, -we’re not changingthe lifetimes of any values passed in or returned. Rather, +we’re not changing the lifetimes of any values passed in or returned. Rather, we’re specifying that the borrow checker should reject any values that don’t adhere to these constraints. Note that the `longest` function doesn’t need to know exactly how long `x` and `y` will live, only that some scope can be