Skip to content

Confusing use of "wildcard" in destructuring pattern documentation #1845

Open
@archer-321

Description

@archer-321

The reference contains the following sentence as patterns.destructure.placeholder:

In a pattern whose scrutinee expression has a struct, enum or tuple type, a placeholder (_) stands in for a single data field, whereas a wildcard .. stands in for all the remaining fields of a particular variant.

The same page defines the _ pattern as a wildcard pattern and .. as a rest pattern. Is this difference intended?

The line was introduced by 0003310e.

If this is indeed an inconsistency, would the following be an acceptable patch?

- In a pattern whose [scrutinee] expression has a `struct`, `enum` or `tuple` type, a placeholder (`_`) stands in for a *single* data field, whereas a wildcard `..`  stands in for *all* the remaining fields of a particular variant.
+ In a pattern whose [scrutinee] expression has a `struct`, `enum` or `tuple` type, a wildcard pattern (`_`) stands in for a *single* data field, whereas a rest pattern (`..`)  stands in for *all* the remaining fields of a particular variant.

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