Macro anyhash::impl_hash

source ·
impl_hash!() { /* proc-macro */ }
Expand description

Implement Hash for types that already implement core::hash::Hash. Only use this if you can’t use the derive macro or implement Hash yourself. This will panic if core::hash::Hasher::finish is called during hashing.

// Implements `Hash` for `MyType`.
impl_hash!(MyType);

You can pass multiple types as arguments. Types are separated by ;.

// Implements `Hash` for `MyOtherType<u32>` and `MyOtherType<u64>`.
impl_hash!(MyOtherType<u32>; MyOtherType<u64>);

You can also pass generic types using the impl keyword.

// Implements `Hash` for `MyType` and `MyOtherType`.
impl_hash! {
    impl<T: core::hash::Hash> MyType<T>;
    impl<'a, T: core::hash::Hash, U: 'a + core::hash::Hash> MyOtherType<'a, T, u32, U> where Self: Display;
}