Skip to content

Commit 6ae5d86

Browse files
committed
Ch. 17: drop lifetime not required in 2024 Edition
This makes for a nicely simpler introduction of this feature!
1 parent ca030dd commit 6ae5d86

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/ch17-01-futures-and-syntax.md

+1-8
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ defined like this:
162162
use std::future::Future;
163163
use trpl::Html;
164164

165-
fn page_title(url: &str) -> impl Future<Output = Option<String>> + '_ {
165+
fn page_title(url: &str) -> impl Future<Output = Option<String>> {
166166
async move {
167167
let text = trpl::get(url).await.text().await;
168168
Html::parse(&text)
@@ -188,13 +188,6 @@ Let’s walk through each part of the transformed version:
188188
- The new function body is an `async move` block because of how it uses the
189189
`url` parameter. (We’ll talk much more about `async` versus `async move` later
190190
in the chapter.)
191-
- The new version of the function has a kind of lifetime we haven’t seen before
192-
in the output type: `'_`. Because the function returns a future that refers to
193-
a reference—in this case, the reference from the `url` parameter—we need to
194-
tell Rust that we want that reference to be included. We don’t have to name
195-
the lifetime here, because Rust is smart enough to know there’s only one
196-
reference that could be involved, but we _do_ have to be explicit that the
197-
resulting future is bound by that lifetime.
198191

199192
Now we can call `page_title` in `main`.
200193

0 commit comments

Comments
 (0)