//! # Examples
//!
//! ```rust
- //! use std::hash::{Hash, SipHasher, Hasher};
+ //! use std::collections::hash_map::DefaultHasher;
+ //! use std::hash::{Hash, Hasher};
//!
//! #[derive(Hash)]
//! struct Person {
//! 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 };
+ //! 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(&person1) != hash(&person2));
+ //! assert!(calculate_hash(&person1) != calculate_hash(&person2));
//!
- //! fn hash<T: Hash>(t: &T) -> u64 {
- //! let mut s = SipHasher::new();
+ //! fn calculate_hash<T: Hash>(t: &T) -> u64 {
+ //! let mut s = DefaultHasher::new();
//! t.hash(&mut s);
//! s.finish()
//! }
//! [`Hash`]: trait.Hash.html
//!
//! ```rust
- //! use std::hash::{Hash, Hasher, SipHasher};
+ //! use std::collections::hash_map::DefaultHasher;
+ //! use std::hash::{Hash, Hasher};
//!
//! struct Person {
//! id: u32,
- //! # #[allow(dead_code)]
+ //! # #[allow(dead_code)]
//! 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 };
+ //! 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_eq!(hash(&person1), hash(&person2));
+ //! assert_eq!(calculate_hash(&person1), calculate_hash(&person2));
//!
- //! fn hash<T: Hash>(t: &T) -> u64 {
- //! let mut s = SipHasher::new();
+ //! fn calculate_hash<T: Hash>(t: &T) -> u64 {
+ //! let mut s = DefaultHasher::new();
//! t.hash(&mut s);
//! s.finish()
//! }
///
/// This trait can be used with `#[derive]` if all fields implement `Hash`.
/// When `derive`d, the resulting hash will be the combination of the values
-/// from calling [`.hash()`] on each field.
+/// from calling [`.hash`] on each field.
///
/// ## How can I implement `Hash`?
///
/// [`Eq`]: ../../std/cmp/trait.Eq.html
/// [`HashMap`]: ../../std/collections/struct.HashMap.html
/// [`HashSet`]: ../../std/collections/struct.HashSet.html
-/// [`.hash()`]: #tymethod.hash
+/// [`.hash`]: #tymethod.hash
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Hash {
/// Feeds this value into the state given, updating the hasher as necessary.