Different Target for Deref and DerefMut

295 Views Asked by At

I am trying to create a wrapper type around a cxx::UniquePtr<A>.

I want to implement struct B(UniquePtr<A>) with

Deref<Target=UniquePtr<A>> for B

but also

DerefMut<Target=Pin<&mut A>> for B {}

Is this a terrible idea or even possible? The whole point of B is to hide the type complexity of UniquePtr<A>. Right now I am forcing my users to call .pin_mut() every time they want to do something and it is quite ugly and breaks their code auto completion. Does anyone have any suggestions or resources I should look at to clean up the interface?

0

There are 0 best solutions below