cognitive-engineering-lab / rust-book

The Rust Programming Language: Experimental Edition
https://rust-book.cs.brown.edu
Other
642 stars 100 forks source link

Chapter 17.1 - page_title example function referred to as page_url_for #220

Open devindumke opened 3 weeks ago

devindumke commented 3 weeks ago

URL to the section(s) of the book with this problem: https://rust-book.cs.brown.edu/ch17-01-futures-and-syntax.html

Description of the problem: In Chapter 17.1 Futures and the Async Syntax, we create a function to demonstrate the async syntax:

use trpl::Html;

async fn page_title(url: &str) -> Option<String> {
    let response = trpl::get(url).await;
    let response_text = response.text().await;
    Html::parse(&response_text)
        .select_first("title")
        .map(|title_element| title_element.inner_html())
}

Later on in the page, we refer back to this function with the suggestion to modify it.

_As a result, we can change the body of page_urlfor to chain the trpl::get and text function calls together with await between them, as shown in Listing 17-2:

The above sentence implies that the function we should modify is _page_urlfor, but the function is called _pagetitle. The term _page_urlfor does not show up anywhere in Chapter 17.

Suggested fix: Change the sentence listed above in Chapter 17.1 to refer to the function as _pagetitle.