Skip to content

Guards example may be confusing #1539

Closed
@skade

Description

@skade

In https://doc.rust-lang.org/rust-by-example/flow_control/match/guard.html, it is stated that:

Note that the compiler does not check arbitrary expressions for whether all possible conditions have been checked. Therefore, you must use the _ pattern at the end.

I was teaching a class today where someone interpreted this sentence as _ being mandatory when using guard expressions. They were weirded out because of an example where I bound to a variable instead (bc. the guards weren't covering) and didn't know that was possible.

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