Kimundi / owning-ref-rs

A library for creating references that carry their owner with them.
MIT License
362 stars 50 forks source link

`OwningHandle` should not require `H: Deref` #18

Closed jonhoo closed 7 years ago

jonhoo commented 7 years ago

Unless I'm mistaken, there is no explicit need for OwningHandle to require that H: Deref. This is only a requirement for the impl Deref for OwningHandle, not for the wrapper type in general?

jonhoo commented 7 years ago

Just did some reading on https://github.com/Kimundi/owning-ref-rs/pull/15, and it seems like it might be needed, though for safety reasons? This is extremely limiting if you have, say a generic enum inside an OwningHandle, because you can't reasonably implement Deref for it. Following https://github.com/Kimundi/owning-ref-rs/pull/15#issuecomment-262142161, is it better to simply drop the bound?

jonhoo commented 7 years ago

And, after reading a bit more, it seems like the solution is to always box the handle of the inner "thing" inside the OwningHandle.