Skip to content

Conversation

A4-Tacks
Copy link
Contributor

Example

trait Foo {
    fn f(&self) -> i32;

    fn foo(&self) -> i32 {
        $0self.f()+self.f()$0
    }
}

Before this PR:

trait Foo {
    fn f(&self) -> i32;

    fn foo(&self) -> i32 {
        self.fun_name()
    }
}

fn $0fun_name(&self) -> i32 {
    self.f()+self.f()
}

After this PR:

trait Foo {
    fn f(&self) -> i32;

    fn foo(&self) -> i32 {
        self.fun_name()
    }

    fn $0fun_name(&self) -> i32 {
        self.f()+self.f()
    }
}

Example
---
```rust
trait Foo {
    fn f(&self) -> i32;

    fn foo(&self) -> i32 {
        $0self.f()+self.f()$0
    }
}
```

**Before this PR**:

```rust
trait Foo {
    fn f(&self) -> i32;

    fn foo(&self) -> i32 {
        self.fun_name()
    }
}

fn $0fun_name(&self) -> i32 {
    self.f()+self.f()
}
```

**After this PR**:

```rust
trait Foo {
    fn f(&self) -> i32;

    fn foo(&self) -> i32 {
        self.fun_name()
    }

    fn $0fun_name(&self) -> i32 {
        self.f()+self.f()
    }
}
```
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 19, 2025
@flodiebold
Copy link
Member

I'm not sure adding the method to the trait is usually going to be what the user wants?

@A4-Tacks
Copy link
Contributor Author

A4-Tacks commented Oct 19, 2025

I'm not sure adding the method to the trait is usually going to be what the user wants?

But it may be appropriate to do so instead of creating a generic function with all trait bounds and trait generic parameters

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.

3 participants