Function addr_eq

#[must_use = "pointer comparison produces a value"]
pub fn addr_eq<T: PointeeSized, U: PointeeSized>(p: *const T, q: *const U) -> bool

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));