Add ide-assist: generate blanket trait impl
Close rust-lang/rust-analyzer#19768
This is very convenient for extending traits such as Iterator
Assist: generate_blanket_trait_impl
Generate blanket trait implementation.
trait $0Foo<T: Send>: ToOwned
where
Self::Owned: Default,
{
fn foo(&self) -> T;
fn print_foo(&self) {
println!("{}", self.foo());
}
}
->
trait Foo<T: Send>: ToOwned
where
Self::Owned: Default,
{
fn foo(&self) -> T;
fn print_foo(&self) {
println!("{}", self.foo());
}
}
$0impl<T: Send, This: ToOwned> Foo<T> for This
where
Self::Owned: Default,
{
fn foo(&self) -> T {
todo!()
}
}
The indentation still seems to have some minor issues
@Veykril May I ask if these PRs can be merged?
r? @Veykril
r? @ShoyuVanilla
:warning: Warning :warning:
-
The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.
- b0cf5ee0ef2fda1e29401b2f44a670e9f3e55cfc
You can start a rebase with the following commands:
$ # rebase $ git pull --rebase https://github.com/rust-lang/rust-analyzer.git master $ git push --force-with-lease
I think this overlaps with #19938? Though this adds blanket impls but I think they share lots of codes and we could reduce duplicates
I think this overlaps with #19938? Though this adds blanket impls but I think they share lots of codes and we could reduce duplicates
I compared the differences between these two and it doesn't seem like there's much shared code
Okay, I'll look into this more but it might take some time as I have other works for now 😅
@ShoyuVanilla Do you have time to review this PR?
Sorry, not yet (I've been sick these days 😅 ) I'll review this tomorrow.
Okay, thank you for taking the time to review