Skip to content

Conversation

@A4-Tacks
Copy link
Member

Example

enum Foo {
    Num(i32)
}

impl Foo {
    fn try_into_num(self) -> Result<i32, Self> {
        if let Self::Num(v) = self {
            Ok(v)
        } else {
            Err(self)
        }
    }
}
fn handle(foo: Foo) {
    foo.try_into_num().$0
}

Before this PR

fn handle(foo: Foo) {
    if let Ok(${1:try_into_num}) = foo.try_into_num() {
        $0
    }
}

After this PR

fn handle(foo: Foo) {
    if let Ok(${1:num}) = foo.try_into_num() {
        $0
    }
}

Example
---
```rust
enum Foo {
    Num(i32)
}

impl Foo {
    fn try_into_num(self) -> Result<i32, Self> {
        if let Self::Num(v) = self {
            Ok(v)
        } else {
            Err(self)
        }
    }
}
fn handle(foo: Foo) {
    foo.try_into_num().$0
}
```

**Before this PR**

```rust
fn handle(foo: Foo) {
    if let Ok(${1:try_into_num}) = foo.try_into_num() {
        $0
    }
}
```

**After this PR**

```rust
fn handle(foo: Foo) {
    if let Ok(${1:num}) = foo.try_into_num() {
        $0
    }
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 28, 2025
@ShoyuVanilla ShoyuVanilla added this pull request to the merge queue Jan 2, 2026
Merged via the queue into rust-lang:master with commit ff83c9f Jan 2, 2026
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 2, 2026
@A4-Tacks A4-Tacks deleted the sugg-name-prefix-try-into branch January 2, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants