I’m very new to Rust, so forgive me it’s something simple (probably is).
I’m trying to use a HashMap (with a custom hasher) with a key type [u8; 40]. The compiler obviously tells me, that I could only use up to length 32, above that I would have to implement a lot of Traits.
In current version of Rust arrays are very limited. It’s going to be fixed eventually when const generics are aded.
You can pass a slice to a custom hasher. Instead of foo: [u8; 40] pass &foo, which will be a variable-length slice of &[u8], and it supports hash for any length.
For automatically derived traits use newtype instead of the raw array:
pub struct MyKey([u8; 40]);
impl Hash for MyKey {…a chunk of code goes here. you can reuse hash of slices…}