The question is in the title. Reference code:
pub trait A<T, E>: Sized {
fn foo(value: &mut T) -> Result<(), E>;
fn bar(value: T) -> Self;
}
pub trait B: Sized + A<Self::T, Self::E> {
type T;
type E;
fn bar(mut value: Self::T) -> Result<Self, Self::E> {
// Can I do something like this?
// type A = Self as A<Self::T, Self::E>;
// match A::foo(&mut value) { ... }
match <Self as A<Self::T, Self::E>>::foo(&mut value) {
Ok(_) => Ok(<Self as A<Self::T, Self::E>>::bar(value)),
Err(error) => Err(error),
}
}
}
It's fine when the code is short. But I have multiple methods inside trait B
, all using functions of trait A
. It gets messy very fast.