This works. But it is comparing the entire contents of "Item", as you can see from here:
Suppose "Item" is a very big object (a graphics mesh in my case). I want to have a set or hash of the object identity (the 'address' of course) inside the Arc, without hashing the entire contents of the object. Is there some way to safely do that?
Address identity gets a lot messier with zero-sized types/type-erased types/generic types/more than one type, but if we're just talking about
Sized and not a ZST, you can implement
Hash yourself and hash the address of the
You'll also need to do the analogous thing for
PartialEq and maybe
Ord and whatnot.
You can't override the implementation of
Arc<_> itself, so you would need to do these things on
KnownType or a newtype or other container of the
Or perhaps a generic wrapper of
"Foo" != "Foo" is surprising.
Another option besides newtypes is to use hashbrown's HashTable which lets one use custom hashing and equality functions.