1
Fork 0

Add an assert_eq in ptr::hash's doc example

This commit is contained in:
Dale Wijnand 2018-11-27 16:46:24 +00:00
parent 81251491dd
commit afb4fbd951
No known key found for this signature in database
GPG key ID: 4F256E3D151DF5EF

View file

@ -2524,7 +2524,13 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
///
/// let mut hasher = DefaultHasher::new();
/// ptr::hash(five_ref, &mut hasher);
/// println!("Hash is {:x}!", hasher.finish());
/// let actual = hasher.finish();
///
/// let mut hasher = DefaultHasher::new();
/// (five_ref as *const T).hash(&mut hasher);
/// let expected = hasher.finish();
///
/// assert_eq!(actual, expected);
/// ```
#[unstable(feature = "ptr_hash", reason = "newly added", issue = "56285")]
pub fn hash<T, S: hash::Hasher>(hashee: &T, into: &mut S) {