Skip to content

Commit afb4fbd

Browse files
committed
Add an assert_eq in ptr::hash's doc example
1 parent 8125149 commit afb4fbd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libcore/ptr.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,13 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
25242524
///
25252525
/// let mut hasher = DefaultHasher::new();
25262526
/// ptr::hash(five_ref, &mut hasher);
2527-
/// println!("Hash is {:x}!", hasher.finish());
2527+
/// let actual = hasher.finish();
2528+
///
2529+
/// let mut hasher = DefaultHasher::new();
2530+
/// (five_ref as *const T).hash(&mut hasher);
2531+
/// let expected = hasher.finish();
2532+
///
2533+
/// assert_eq!(actual, expected);
25282534
/// ```
25292535
#[unstable(feature = "ptr_hash", reason = "newly added", issue = "56285")]
25302536
pub fn hash<T, S: hash::Hasher>(hashee: &T, into: &mut S) {

0 commit comments

Comments
 (0)