Hello,
I want to define a trait with two associative types where I Implemented TryFrom<A> to B however, I can't seem to get rust to accept syntax, it complains about needing From<A> to B whilst that's not what is available due to possible conversion errors... Any tips?
pub trait MiddlewareType {
type ProtoType: Message + Default where Self::ProtoType: TryFrom<Self::RustType>, <Self::ProtoType as TryFrom<Self::RustType>>::Error: std::fmt::Debug;
type RustType: Clone;
fn into_proto(value: Self::RustType) -> Result<Self::ProtoType, Box<dyn std::error::Error>> {
Self::ProtoType::try_from(value).map_err(|e| e.into())
}
}
the trait bound `<Self as MiddlewareType>::ProtoType: From<<Self as MiddlewareType>::RustType>` is not satisfied
required for `<Self as MiddlewareType>::RustType` to implement `Into<<Self as MiddlewareType>::ProtoType>`
required for `<Self as MiddlewareType>::ProtoType` to implement `TryFrom<<Self as MiddlewareType>::RustType>`rustc
mw.rs(71, 96): consider further restricting the associated type: ` where <Self as MiddlewareType>::ProtoType: From<<Self as MiddlewareType>::RustType>`
(adding the suggested restriction also doesn't solve the issue)