Skip to content

Tutorial ambiguity or mistake re: destructuring & let #11113

Closed
@olliebun

Description

@olliebun

From the tutorial:

You've already seen simple let bindings, but let is a little fancier than you've been led to believe. It, too, supports destructuring patterns. For example, you can write this to extract the fields from a tuple, introducing two variables at once: a and b.

let (a, b) = get_tuple_of_two_ints();

Let bindings only work with irrefutable patterns: that is, patterns that can never fail to match. This excludes let from matching literals and most enum variants.

(emphasis mine)

This code compiles and behaves as expected:

let (a, b) = (1,2);

Have not included a pull request, as I'm not sure what the meaning of the passage is otherwise.

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