Skip to content

Conversation

A4-Tacks
Copy link
Contributor

Replace matches!() to let-chain in if condition.

Example

fn foo(x: Option<i32>) {
    if let Some(n) = x && $0matches!(n.checked_div(2), Some(5..8)) {
    }
}

->

fn foo(x: Option<i32>) {
    if let Some(n) = x && let Some(5..8) = n.checked_div(2) {
    }
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 19, 2025
Replace matches!() to let-chain in if condition.

Example
---
```rust
fn foo(x: Option<i32>) {
    if let Some(n) = x && $0matches!(n.checked_div(2), Some(5..8)) {
    }
}
```
->
```rust
fn foo(x: Option<i32>) {
    if let Some(n) = x && let Some(5..8) = n.checked_div(2) {
    }
}
```
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