Try to fix ptr::hash's doc example

This commit is contained in:
Dale Wijnand 2018-11-27 20:09:18 +00:00
parent 4a7ffe2646
commit 9755410f73
No known key found for this signature in database
GPG key ID: 4F256E3D151DF5EF

View file

@ -2516,18 +2516,19 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
///
/// ```
/// use std::collections::hash_map::DefaultHasher;
/// use std::hash::Hasher;
/// use std::hash::{Hash, Hasher};
/// use std::ptr;
///
/// let five = 5;
/// let five_ref = &five;
///
/// let mut hasher = DefaultHasher::new();
/// #[feature(ptr_hash)]
/// ptr::hash(five_ref, &mut hasher);
/// let actual = hasher.finish();
///
/// let mut hasher = DefaultHasher::new();
/// (five_ref as *const T).hash(&mut hasher);
/// (five_ref as *const i32).hash(&mut hasher);
/// let expected = hasher.finish();
///
/// assert_eq!(actual, expected);