Skip to content

Commit

Permalink
Add an assert_eq in ptr::hash's doc example
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Nov 27, 2018
1 parent 8125149 commit afb4fbd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/libcore/ptr.rs
Expand Up @@ -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) {
Expand Down

0 comments on commit afb4fbd

Please sign in to comment.