Skip to content

Possible typo in Chapter 19.2: missing if in if let examples #4413

Open
@raymalt

Description

@raymalt

Hi Rust Book team,

Thank you for your amazing work on the Rust Book, it’s been an incredibly helpful resource for learning Rust!

While reading Chapter 19.2 on Refutability, I noticed that a couple of examples seem to be missing the if keyword in what appear to be if let statements.

For example, there’s an instance like this:

let Some(x) = a_value {
// …
}

I believe this might be a typo, and it should instead be:

if let Some(x) = a_value {
// …
}

As far as I understand, using let like that without if would result in a compilation error due to the pattern possibly being non-exhaustive.

Of course, please correct me if I’ve misunderstood the context. Just wanted to point this out in case it’s unintentional.

Thanks!

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