I’m implementing a method of a trait. To avoid the method becoming huge spaghetti code I want to break down the implementation into smaller methods.
Unfortunately when I add other “private” methods to the trait impl, I’m getting error E0407.
trait QuackTwice {
fn quack_twice();
}
impl<T> QuackTwice for Complicated<Type> where Lots<Of::Things<Tediously<T>>>: Declared {
fn quack_twice() {
Self::quack();
Self::quack();
}
fn quack() {
// implementation
}
}
This limitation is annoying because if I move quack
anywhere else, I’ll have to repeat the Lots<Of::Things<Tediously>>: Declared
part, which in my particular case is 5 lines of complex declarations.
Can I add “private” helper methods to trait implementations? If not, is there another way to move code into a helper method without duplicating the painfully large where
clause?