Skip to content

Commit

Permalink
Merge pull request #84 from stepancheg/addr-eq
Browse files Browse the repository at this point in the history
Use ptr::addr_eq instead of == in Arc::ptr_eq
  • Loading branch information
Manishearth committed Apr 17, 2024
2 parents 8922bc1 + e0b7dd2 commit 0db2a24
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ impl<T: ?Sized> Arc<T> {
let _ = Box::from_raw(self.ptr());
}

/// Test pointer equality between the two Arcs, i.e. they must be the _same_
/// allocation
/// Returns `true` if the two `Arc`s point to the same allocation in a vein similar to
/// [`ptr::eq`]. This function ignores the metadata of `dyn Trait` pointers.
#[inline]
pub fn ptr_eq(this: &Self, other: &Self) -> bool {
this.ptr() == other.ptr()
ptr::addr_eq(this.ptr(), other.ptr())
}

pub(crate) fn ptr(&self) -> *mut ArcInner<T> {
Expand Down

0 comments on commit 0db2a24

Please sign in to comment.