rust-lang / rust-lang/book

Mismatched variable name in ch17-05 code example

Open Beginner friendly
#4,444 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
18.3k
Forks
4.1k
Avg merge
14m
Merged PRs (30d)
1

Description

In the "The Future Trait" section of ch17-05, the current code shows:

let mut page_title_fut = page_title(url);
loop {
    match page_title_fut.poll() {
        Ready(value) => match page_title {  // Incorrect: `value` is matched but `page_title` is used
            Some(title) => println!("The title for {url} was {title}"),
            None => println!("{url} had no title"),
        }
        Pending => {
            // continue
        }
    }
}

It should be:

let mut page_title_fut = page_title(url);
loop {
    match page_title_fut.poll() {
        Ready(page_title) => match page_title {  // Fixed: Consistent naming
            Some(title) => println!("The title for {url} was {title}"),
            None => println!("{url} had no title"),
        }
        Pending => {
            // continue
        }
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Find the ch17-05 code example in the "The Future Trait" section and compare it with the issue's corrected snippet. Update the mismatched variable name, then build or render the book and confirm the example is consistent and valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.