rust-analyzer
rust-analyzer copied to clipboard
Feature request: split trait
Let’s say I have a trait such as
trait T {
pub fn foo(&self, a: i32) -> bool;
pub fn bar<A>(&self, a: A, b: A) -> A;
pub fn baz(&self) -> &'static str;
}
I want to split T into two traits: T1 (containing foo and bar) and T2 (containing baz). My suggested action would do the following:
- Prompt for which items to assign to
T1and which to assign toT2 - Create these traits
- Optionally retain
Tas a subtrait ofT1 + T2with a blanket implementation - Refine trait bounds of the type
A: TtoA: T1orA: T2if they use items from only one of them - Split all implementations of
Tas well
The opposite action (merging two traits) could be added as well, although I don’t know how useful it would be in practice.