Skip to content

CodeAction: Generate blanket trait implementation #19768

Open
@A4-Tacks

Description

@A4-Tacks

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!()
    }
}

Metadata

Metadata

Assignees

Labels

C-featureCategory: feature request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions