Since you can use a custom
Hasher with a
HashMap, is there a non-hashing version for basic, fixed-size key types (e.g.
usize, or a tuple of two
usize values, or even
enum variants?). I see that the hasher trait write methods take various size primitives or
&[u8] and so need to work with any length input (bah strings!). Thus a
HashMap<usize, T> bounds the keys' range, but only outside of the knowledge/control of the hasher, so that's probably a fun disconnect...
One workaround, since I'm using monotonically increasing integers as keys, would be a
HashMap based on a
Vec that never renumbers its indices if elements are removed. So just a
Vec<Option<T>> with the remove method setting the appropriate item to
None. But then that limits it to only work with
usize keys, and will lead to bloat if common use is to stay at a small number of items by regular paired add/delete ops.
It seems that at least somebody has considered this, as there is the vec_map crate. But, fortunately, a plain
HashMap<usize, T> will "just work", so this is just an excuse to explore the intricacies of Rust. Nonetheless, any help or discussion is welcomed. Thanks!