Use addr_eq
in {Arc,Rc}::ptr_eq
Since it's made for stuff like this (see 106447)
This commit is contained in:
parent
2e5a9dd6c9
commit
f8fc0d7716
3 changed files with 5 additions and 4 deletions
|
@ -140,6 +140,7 @@
|
|||
#![feature(maybe_uninit_uninit_array_transpose)]
|
||||
#![feature(pattern)]
|
||||
#![feature(pointer_byte_offsets)]
|
||||
#![feature(ptr_addr_eq)]
|
||||
#![feature(ptr_internals)]
|
||||
#![feature(ptr_metadata)]
|
||||
#![feature(ptr_sub_ptr)]
|
||||
|
|
|
@ -1649,7 +1649,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
|
|||
/// assert!(!Rc::ptr_eq(&five, &other_five));
|
||||
/// ```
|
||||
pub fn ptr_eq(this: &Self, other: &Self) -> bool {
|
||||
this.ptr.as_ptr() as *const () == other.ptr.as_ptr() as *const ()
|
||||
ptr::addr_eq(this.ptr.as_ptr(), other.ptr.as_ptr())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3146,7 +3146,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
|
|||
#[must_use]
|
||||
#[stable(feature = "weak_ptr_eq", since = "1.39.0")]
|
||||
pub fn ptr_eq(&self, other: &Self) -> bool {
|
||||
ptr::eq(self.ptr.as_ptr() as *const (), other.ptr.as_ptr() as *const ())
|
||||
ptr::addr_eq(self.ptr.as_ptr(), other.ptr.as_ptr())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1778,7 +1778,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
|
|||
#[must_use]
|
||||
#[stable(feature = "ptr_eq", since = "1.17.0")]
|
||||
pub fn ptr_eq(this: &Self, other: &Self) -> bool {
|
||||
this.ptr.as_ptr() as *const () == other.ptr.as_ptr() as *const ()
|
||||
ptr::addr_eq(this.ptr.as_ptr(), other.ptr.as_ptr())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2900,7 +2900,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
|
|||
#[must_use]
|
||||
#[stable(feature = "weak_ptr_eq", since = "1.39.0")]
|
||||
pub fn ptr_eq(&self, other: &Self) -> bool {
|
||||
ptr::eq(self.ptr.as_ptr() as *const (), other.ptr.as_ptr() as *const ())
|
||||
ptr::addr_eq(self.ptr.as_ptr(), other.ptr.as_ptr())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue