Skip to content

CodeAction: Generate blanket trait implementation #19768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
A4-Tacks opened this issue May 9, 2025 · 1 comment · May be fixed by #19771
Open

CodeAction: Generate blanket trait implementation #19768

A4-Tacks opened this issue May 9, 2025 · 1 comment · May be fixed by #19771
Assignees
Labels
C-feature Category: feature request

Comments

@A4-Tacks
Copy link
Contributor

A4-Tacks commented May 9, 2025

Add a Code Action, Generate blanket trait implementation on trait define

  • Generate This generic param
  • Generate Self bounds to This
  • Generate where-clause bounds
  • Generate required methods, use todo!() fill
trait Foo: ToOwned
where
    Self::Owned: Default,
{
    fn foo(&self) -> i32;

    fn print_foo(&self) {
        println!("{}", self.foo());
    }
}

On trait Foo use Generate blanket trait implementation:

trait Foo: ToOwned
where
    Self::Owned: Default,
{
    fn foo(&self) -> i32;

    fn print_foo(&self) {
        println!("{}", self.foo());
    }
}
impl<This: ToOwned> Foo for This
where
    This::Owned: Default,
{
    fn foo(&self) -> i32 {
        todo!()
    }
}
@A4-Tacks A4-Tacks added the C-feature Category: feature request label May 9, 2025
@A4-Tacks
Copy link
Contributor Author

A4-Tacks commented May 9, 2025

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant