What are you trying to do? Since you cannot have several references to the same “object” in the same way you can in many other languages such as Java, it usually doesn't make sense to perform this operation.
If you are using a smart pointer like
Rc that allows you to have several references to the same object, they typically have a dedicated method (e.g.
ptr_eq) for doing an equality check. In the specific case of an
Rc, you can call
into_raw to obtain a pointer which you can cast to
usize and then hash.
If you must, you can use a similar method on
Vec, which returns a pointer you can cast to usize and hash. However if the vec runs out of capacity, it will reallocate which results in a new hash.