heapless icon indicating copy to clipboard operation
heapless copied to clipboard

How to use `enum` as K in `FnvIndexMap`

Open TENX-S opened this issue 1 year ago • 0 comments

I have an enum that I want to use as the key type in an FnvIndexMap.:

use hash32_derive::Hash32;

#[derive(Hash, Hash32)]
pub enum Command {
  // ...
}
// says "#[derive(Hash)] doesn't currently support `enum` and `union`"

static M: FnvIndexMap<Command, u32, 3> = FnvIndexMap::from_iter([(Command::Send, 1)]);
// says `the trait bound `Command: hash32::Hash` is not satisfied`

I noticed that a related issue https://github.com/japaric/hash32/issues/3 has been closed, but it seems that the problem still persists.

TENX-S avatar May 13 '23 00:05 TENX-S