Macro ident::impl_hash_identity
[−]
[src]
macro_rules! impl_hash_identity { (($type:tt, $hasher:tt)) => { ... }; (($type:tt, $hasher:tt) $($t:tt)*) => { ... }; ($type:tt, $hasher:tt) => { ... }; }
A hash is often a useful and convenient identifier
value.
This macro implements DeriveIdent<u64>
for the passed
type using the passed Hasher
.
(NOTE: the type must derive Hash
)
Examples
#[macro_use] extern crate ident; use std::collections::hash_map::DefaultHasher; use ident::*; #[derive(Hash)] struct MyType(pub usize); //Implements DeriveIdent<u64> for MyType using DefaultHasher to calculate the hash. impl_hash_identity!(MyType, DefaultHasher); fn main() { let x = MyType(5); println!("{}", DeriveIdent::<u64>::derive_ident(&x)); }