Borrow to another type


I have these two wrapper types:

struct Wrapper(Box<Trait>);
struct RefWrapper<'a>(&'a Trait);

(They are necessary, because of the Eq and Hash trait, as they are not implementable on trait objects due to trait object safety rules. So im doing some magic to implement Eq and Hash on the wrappers.)

Now i need to borrow from Wrapper to RefWrapper:

impl <'a> Borrow<RefWrapper<'a>> for Wrapper {
    fn borrow(&'a self) -> RefWrapper<'a> {
        RefWrapper (self.0.borrow())

but that isn’t working for obvious reason:

method `borrow` has an incompatible type for trait
pub trait Borrow<Borrowed: ?Sized> {
    fn borrow(&self) -> &Borrowed;


This is very similar to the problems with Deref only returning borrowed values: I am not aware of any solutions.