File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ defined like this:
162162use std :: future :: Future ;
163163use 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
199192Now we can call ` page_title ` in ` main ` .
200193
You can’t perform that action at this time.
0 commit comments