Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Variable labeling of complex match arms should be able to label the whole arm #15219

Copy link
Copy link
@Manishearth

Description

@Manishearth
Issue body actions

If I have a match arm like this:

0x2A | 0x2D | 0x2E | 0x30 .. 0x39 | 0x41 .. 0x5A | 0x5F | 0x61..0x7A => {}

the following does not work:

a @ 0x2A | 0x2D | 0x2E | 0x30 .. 0x39 | 0x41 .. 0x5A | 0x5F | 0x61..0x7A => {println("{}",a)}
a @ (0x2A | 0x2D | 0x2E | 0x30 .. 0x39 | 0x41 .. 0x5A | 0x5F | 0x61..0x7A) => {println("{}",a)}

In the former example, the a is bound to the first literal only, and in the latter the compiler thinks that it is a tuple (and complains about the lack of commas).

Of course, one can do

a @ 0x2A | a @ 0x2D | a@ 0x2E | a@ 0x30 .. 0x39 /* etc */=> {println("{}",a)}

but that is cumbersome.

Could we get a way to easily bind a variable to the entire match arm?

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.