File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2509,6 +2509,29 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
2509
2509
a == b
2510
2510
}
2511
2511
2512
+ /// Hash the raw pointer address behind a reference, rather than the value
2513
+ /// it points to.
2514
+ ///
2515
+ /// # Examples
2516
+ ///
2517
+ /// ```
2518
+ /// use std::collections::hash_map::DefaultHasher;
2519
+ /// use std::hash::Hasher;
2520
+ /// use std::ptr;
2521
+ ///
2522
+ /// let five = 5;
2523
+ /// let five_ref = &five;
2524
+ ///
2525
+ /// let mut hasher = DefaultHasher::new();
2526
+ /// ptr::hash(five_ref, hasher);
2527
+ /// println!("Hash is {:x}!", hasher.finish());
2528
+ /// ```
2529
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ] // TODO: replace with ???
2530
+ pub fn hash < T , S : hash:: Hasher > ( a : & T , into : & mut S ) {
2531
+ use hash:: Hash ;
2532
+ NonNull :: from ( a) . hash ( into)
2533
+ }
2534
+
2512
2535
// Impls for function pointers
2513
2536
macro_rules! fnptr_impls_safety_abi {
2514
2537
( $FnTy: ty, $( $Arg: ident) ,* ) => {
You can’t perform that action at this time.
0 commit comments