pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool
🔬This is a nightly-only experimental API. (
ptr_addr_eq
#116324)Expand description
Compares the addresses of the two pointers for equality, ignoring any metadata in fat pointers.
If the arguments are thin pointers of the same type,
then this is the same as eq
.
Examples
#![feature(ptr_addr_eq)]
let whole: &[i32; 3] = &[1, 2, 3];
let first: &i32 = &whole[0];
assert!(std::ptr::addr_eq(whole, first));
assert!(!std::ptr::eq::<dyn std::fmt::Debug>(whole, first));
Run