File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1868,6 +1868,28 @@ pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {
1868
1868
a == b
1869
1869
}
1870
1870
1871
+ /// Compares the *addresses* of the two pointers for equality,
1872
+ /// ignoring any metadata in fat pointers.
1873
+ ///
1874
+ /// If the arguments are thin pointers of the same type,
1875
+ /// then this is the same as [`eq`].
1876
+ ///
1877
+ /// # Examples
1878
+ ///
1879
+ /// ```
1880
+ /// #![feature(ptr_addr_eq)]
1881
+ ///
1882
+ /// let whole: &[i32; 3] = &[1, 2, 3];
1883
+ /// let first: &i32 = &whole[0];
1884
+ /// assert!(std::ptr::addr_eq(whole, first));
1885
+ /// assert!(!std::ptr::eq::<dyn std::fmt::Debug>(whole, first));
1886
+ /// ```
1887
+ #[ unstable( feature = "ptr_addr_eq" , issue = "116324" ) ]
1888
+ #[ inline( always) ]
1889
+ pub fn addr_eq < T : ?Sized , U : ?Sized > ( p : * const T , q : * const U ) -> bool {
1890
+ ( p as * const ( ) ) == ( q as * const ( ) )
1891
+ }
1892
+
1871
1893
/// Hash a raw pointer.
1872
1894
///
1873
1895
/// This can be used to hash a `&T` reference (which coerces to `*const T` implicitly)
You can’t perform that action at this time.
0 commit comments