If you implement the Deref
trait, for the most part, your &T
can act like and be used in the place of &Target
.
This is how Box
acts is usable like the T
it wraps, alongside the other "smart pointers" such as Arc
and Rc
.
Technically, you should probably have HashRcByLoc<T>: Deref<Target=T>
rather than HashRcByLoc<T>: Deref<Target=Rc<T>>
, due to the specific semantics of Deref
, but any place one type should be used as-if it were another type is a reasonable enough place to impl Deref
.
Also consider using shrinkwraprs to automate some of the newtype-forwarding boilerplate.