Commit 6ae5d86 1 parent ca030dd commit 6ae5d86 Copy full SHA for 6ae5d86
File tree 1 file changed +1
-8
lines changed
1 file changed +1
-8
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ defined like this:
162
162
use std :: future :: Future ;
163
163
use trpl :: Html ;
164
164
165
- fn page_title (url : & str ) -> impl Future <Output = Option <String >> + ' _ {
165
+ fn page_title (url : & str ) -> impl Future <Output = Option <String >> {
166
166
async move {
167
167
let text = trpl :: get (url ). await . text (). await ;
168
168
Html :: parse (& text )
@@ -188,13 +188,6 @@ Let’s walk through each part of the transformed version:
188
188
- The new function body is an ` async move ` block because of how it uses the
189
189
` url ` parameter. (We’ll talk much more about ` async ` versus ` async move ` later
190
190
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.
198
191
199
192
Now we can call ` page_title ` in ` main ` .
200
193
You can’t perform that action at this time.
0 commit comments