Attribute Macro solders_macros::pyhash
source · #[pyhash]
Expand description
Add a __hash__
to the impl using the PyHash
trait.
Example
use solders_macros::pyhash;
#[derive(Debug)]
struct Foo(u8);
#[pyhash]
impl Foo {
pub fn pyhash(&self) -> u64 { // Fake implementation in place of `PyHash`.
self.0.into()
}
}
let foo = Foo(3);
assert_eq!(3, foo.__hash__());