Skip to content

if let for match arm guard? #73764

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
tesuji opened this issue Jun 26, 2020 · 4 comments
Closed

if let for match arm guard? #73764

tesuji opened this issue Jun 26, 2020 · 4 comments
Labels
A-patterns Relating to patterns and pattern matching T-lang Relevant to the language team

Comments

@tesuji
Copy link
Contributor

tesuji commented Jun 26, 2020

Does it have any design for if let in match arm guard?

match "foobar" {
    s if let Some(tail) = tail.strip_prefix("bar") => dbg!(tail),
    _ => "barbaz",
}

Without if let, I have to indent the if expression a bit:

match "foobar" {
    s => {
        if let Some(tail) = tail.strip_prefix("bar") {
            dbg!(tail)
        } else {
            "barbaz"
        }
    }
}
@tesuji

This comment has been minimized.

@rustbot rustbot added A-patterns Relating to patterns and pattern matching T-lang Relevant to the language team labels Jun 26, 2020
@petrochenkov
Copy link
Contributor

@tesuji
Copy link
Contributor Author

tesuji commented Jun 26, 2020

Thanks. So if let for guard hasn't been implemented.
Should I close this issue for #51114 instead ?

@nagisa
Copy link
Member

nagisa commented Jun 26, 2020

Duplicate of #51114

@nagisa nagisa marked this as a duplicate of #51114 Jun 26, 2020
@nagisa nagisa closed this as completed Jun 26, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-patterns Relating to patterns and pattern matching T-lang Relevant to the language team
Projects
None yet
Development

No branches or pull requests

4 participants