Skip to content

feat: supports multi arms for replace_match_with_if_let#22231

Open
A4-Tacks wants to merge 1 commit intorust-lang:masterfrom
A4-Tacks:match-with-iflet-multi
Open

feat: supports multi arms for replace_match_with_if_let#22231
A4-Tacks wants to merge 1 commit intorust-lang:masterfrom
A4-Tacks:match-with-iflet-multi

Conversation

@A4-Tacks
Copy link
Copy Markdown
Member

Example

fn main() {
    match$0 Some(0) {
        Some(n) if n % 2 == 0 && n != 6 => (),
        Some(n) if valided(n) => foo(),
        _ => code(),
    }
}

Before this PR

Assist not applicable

After this PR

fn main() {
    if let Some(n) = Some(0) && (n % 2 == 0 && n != 6) {
        ()
    } else if let Some(n) = Some(0) && valided(n) {
        foo()
    } else {
        code()
    }
}

Example
---
```rust
fn main() {
    match$0 Some(0) {
        Some(n) if n % 2 == 0 && n != 6 => (),
        Some(n) if valided(n) => foo(),
        _ => code(),
    }
}
```

**Before this PR**

Assist not applicable

**After this PR**

```rust
fn main() {
    if let Some(n) = Some(0) && (n % 2 == 0 && n != 6) {
        ()
    } else if let Some(n) = Some(0) && valided(n) {
        foo()
    } else {
        code()
    }
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants