4 /// A wrapper around reference that compares and hashes like a pointer.
5 /// Can be used as a key in sets/maps indexed by pointers to avoid `unsafe`.
7 pub struct PtrKey<'a, T>(pub &'a T);
9 impl<'a, T> Clone for PtrKey<'a, T> {
10 fn clone(&self) -> Self {
15 impl<'a, T> Copy for PtrKey<'a, T> {}
17 impl<'a, T> PartialEq for PtrKey<'a, T> {
18 fn eq(&self, rhs: &Self) -> bool {
19 ptr::eq(self.0, rhs.0)
23 impl<'a, T> Eq for PtrKey<'a, T> {}
25 impl<'a, T> hash::Hash for PtrKey<'a, T> {
26 fn hash<H: hash::Hasher>(&self, hasher: &mut H) {
27 (self.0 as *const T).hash(hasher)
31 impl<'a, T> Deref for PtrKey<'a, T> {
34 fn deref(&self) -> &Self::Target {