about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDale Wijnand <dale.wijnand@gmail.com>2018-11-27 16:46:24 +0000
committerDale Wijnand <dale.wijnand@gmail.com>2018-11-27 16:46:24 +0000
commitafb4fbd951bc9780b5a7812f9a72aa9e2f085814 (patch)
treecf1caf3350927ab1560c4cc13b5ba8168549686f
parent81251491ddecb5c55b6d22b04abf33ef65d3a74b (diff)
downloadrust-afb4fbd951bc9780b5a7812f9a72aa9e2f085814.tar.gz
rust-afb4fbd951bc9780b5a7812f9a72aa9e2f085814.zip
Add an assert_eq in ptr::hash's doc example
-rw-r--r--src/libcore/ptr.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index ff679d92e60..7b93795728b 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -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) {