Closed tatref closed 1 year ago
Converted to draft, as the Hash
for Shm
is probably plain wrong if some fields are not part of the hash
The derived traits seem OK to me, but I agree that the custom impl for Shm
seems a little suspect. For me, the primary purpose to have a type impl Hash
is to be able to use it has a key in a HashMap
. I guess it's not inconceivable that you'd want to do this. Did you have a specific usecase for implementing Hash
on Shm
?
I'm working on a tool for memory diagnostics.
I want to store a list of physical pages used by each shared memory segment, so HashMap<Shm, Vec<Pfn>>
makes a lot of sense.
I'll rework the PR to remove the custom impl stuff.
I'm not saying that procfs
can't implement these, but could you put Shm
in your own local wrapper type, and impl Hash
and PartialEq
according to the rules that make sense for your tool?
After some thinking, I believe that the custom Hash
and PartialEq
that I initially implemented is plain wrong.
I switched to using derive
Tell my if it's good for you
I rebased from master
I implemented a few standard traits, but there's probably others.
For
Shm
, some field likerss
oratime
are not really part of the indentity ofShm
, so I left them out