Function std::ptr::addr_eq

1.76.0 · source ·
pub fn addr_eq<T, U>(p: *const T, q: *const U) -> bool
where T: ?Sized, U: ?Sized,
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

use std::ptr;

let whole: &[i32; 3] = &[1, 2, 3];
let first: &i32 = &whole[0];

assert!(ptr::addr_eq(whole, first));
assert!(!ptr::eq::<dyn std::fmt::Debug>(whole, first));
Run