From afb4fbd951bc9780b5a7812f9a72aa9e2f085814 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 27 Nov 2018 16:46:24 +0000 Subject: [PATCH] Add an assert_eq in ptr::hash's doc example --- src/libcore/ptr.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index ff679d92e609..7b93795728b9 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2524,7 +2524,13 @@ pub fn eq(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(hashee: &T, into: &mut S) {