Skip to content

ch19-02 Listing 19-10 irrefutable vs refutable #4417

@TwelveGem

Description

@TwelveGem
  • I have searched open and closed issues and pull requests for duplicates, using these search terms:
    • ch19-02
  • I have checked the latest main branch to see if this has already been fixed, in this file:
    • ch19-02-refutability.md

URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch19-02-refutability.html#listing-19-10

Description of the problem:
The lines above this listing describe that the Listing uses if let that should be giving a warning because they are putting an irrefutable pattern in, but the listing uses let.

Suggested fix:
listing 19-10 should be changed to

fn main() {
    // ANCHOR: here
    if let x = 5 else {
        return;
    };
    // ANCHOR_END: here
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions