Skip to main content

Hashable

Derive Macro Hashable 

Source
#[derive(Hashable)]
Expand description

Derive macro for implementing the Hashable trait.

This macro automatically implements Hashable for structs by creating nested tuples of field references and calling .hash() on them.

§Example

#[derive(Hashable)]
struct MyStruct {
    x: u64,
    y: u64,
    z: u64,
}

Expands to:

impl Hashable for MyStruct {
    fn hash(&self) -> Digest {
        (&self.x, &(&self.y, &self.z)).hash()
    }
}