Module core::hashStable
[-] [+]
[src]
Generic hashing support.
This module provides a generic way to compute the hash of a value. The
simplest way to make a type hashable is to use #[derive(Hash)]
:
Examples
fn main() { use std::hash::{hash, Hash, SipHasher}; #[derive(Hash)] struct Person { id: uint, name: String, phone: u64, } let person1 = Person { id: 5, name: "Janet".to_string(), phone: 555_666_7777 }; let person2 = Person { id: 5, name: "Bob".to_string(), phone: 555_666_7777 }; assert!(hash::<_, SipHasher>(&person1) != hash::<_, SipHasher>(&person2)); }use std::hash::{hash, Hash, SipHasher}; #[derive(Hash)] struct Person { id: uint, name: String, phone: u64, } let person1 = Person { id: 5, name: "Janet".to_string(), phone: 555_666_7777 }; let person2 = Person { id: 5, name: "Bob".to_string(),