Skip to content

Document @ syntax in pattern matching #11563

Closed
@andrew-3kb

Description

@andrew-3kb

There is a really useful feature currently in the match expression:

match foo {
    ref mut a @ Something(_) => something_else(a),
    ...
}

if you don't know what it does it binds the entire thing matched to a variable, so in the above case something_else will be called with a mutable reference to foo if it meets the pattern Something(_).

The feature seems really useful but it's currently not documented anywhere, I guess someone should document it.

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