Skip to content

Commit

Permalink
document ptr comparison being by address
Browse files Browse the repository at this point in the history
  • Loading branch information
hkBst authored and gitbot committed Feb 20, 2025
1 parent e9388ea commit d45e877
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ impl<T, const N: usize> *const [T; N] {
}
}

// Equality for pointers
/// Pointer equality is by address, as produced by the [`<*const T>::addr`](pointer::addr) method.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> PartialEq for *const T {
#[inline]
Expand All @@ -1691,10 +1691,11 @@ impl<T: ?Sized> PartialEq for *const T {
}
}

/// Pointer equality is an equivalence relation.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Eq for *const T {}

// Comparison for pointers
/// Pointer comparison is by address, as produced by the `[`<*const T>::addr`](pointer::addr)` method.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Ord for *const T {
#[inline]
Expand All @@ -1710,6 +1711,7 @@ impl<T: ?Sized> Ord for *const T {
}
}

/// Pointer comparison is by address, as produced by the `[`<*const T>::addr`](pointer::addr)` method.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> PartialOrd for *const T {
#[inline]
Expand Down
5 changes: 4 additions & 1 deletion core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,7 @@ impl<T, const N: usize> *mut [T; N] {
}
}

// Equality for pointers
/// Pointer equality is by address, as produced by the [`<*mut T>::addr`](pointer::addr) method.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> PartialEq for *mut T {
#[inline(always)]
Expand All @@ -2107,9 +2107,11 @@ impl<T: ?Sized> PartialEq for *mut T {
}
}

/// Pointer equality is an equivalence relation.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Eq for *mut T {}

/// Pointer comparison is by address, as produced by the [`<*mut T>::addr`](pointer::addr) method.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Ord for *mut T {
#[inline]
Expand All @@ -2125,6 +2127,7 @@ impl<T: ?Sized> Ord for *mut T {
}
}

/// Pointer comparison is by address, as produced by the [`<*mut T>::addr`](pointer::addr) method.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> PartialOrd for *mut T {
#[inline(always)]
Expand Down

0 comments on commit d45e877

Please sign in to comment.