Skip to content

Conversation

A4-Tacks
Copy link
Contributor

Converts let statement with if-let initializer to let-else statement.

Example

# //- minicore: option
fn foo(opt: Option<()>) {
    let val$0 = if let Some(it) = opt {
        it
    } else {
        return
    };
}

->

fn foo(opt: Option<()>) {
    let Some(val) = opt else {
        return
    };
}

Converts let statement with if-let initializer to let-else statement.

Example
---
```rust
# //- minicore: option
fn foo(opt: Option<()>) {
    let val$0 = if let Some(it) = opt {
        it
    } else {
        return
    };
}
```
->
```rust
fn foo(opt: Option<()>) {
    let Some(val) = opt else {
        return
    };
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 13, 2025
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