std::ptr::eq
on references RS-W1119std::ptr::eq
can be used to compare &T
references (coerced to *const T
implicitly)
by their address rather than the values they point to.
Hence, use std::ptr::eq
when applicable with &T
references.
fn main() {
let a = &[1, 2, 3];
let b = &[1, 2, 3];
assert!(a as *const _ as usize == b as *const _ as usize);
}
fn main() {
let a = &[1, 2, 3];
let b = &[1, 2, 3];
assert!(std::ptr::eq(a, b));
}