Is there some reason why Borrow
and BorrowMut
do not provide recursive impls like
impl<T: ?Sized, U: Borrow<T>> Borrow<T> for Arc<U> {
fn borrow(&self) -> &T {
**self.borrow()
}
}
I suppose the obvious use cases would be stacks of smart pointers, so the direct impls would look like
impl<T: ?Sized> Borrow<T> for Arc<Box<T>> {
fn borrow(&self) -> &T {
&**self
}
}
And one can avoid these using impl<T: ?Sized> From<Box<T>> for Arc<T>
at the cost larger allocations and copies.
We’d want a different answer if we started placing the Arc
s into arenas or whatever though… or wanted the T: ?Sized
back out frequently.