Is there any chance of extending the trait hierarchy to support transitive closures of Deref[Mut], [Try]From/[Try]Into, (and maybe not existing yet Coerce)?
Such as:
pub trait DerefChain<T: ?Sized> {
fn deref_chain(&self) -> &T;
}
pub trait DerefMutChain<T: ?Sized> {
fn deref_mut_chain(&mut self) -> &mut T;
}
// Bypass some limits of orphan rules
impl<T: Deref<Target: DerefChain<U> + ?Sized, U: ?Sized> DerefChain<U> for T {
fn deref_chain(&self) -> &U {
self.deref().deref_chain()
}
}
// Bypass some limits of orphan rules
impl<T: DerefMut<Target: DerefMutChain<U> + ?Sized, U: ?Sized> DerefMutChain<U> for T {
fn deref_mut_chain(&mut self) -> &mut U {
self.deref_mut().deref_mut_chain()
}
}