Update safety docs for Ptr::assert_unique (#17394)

# Objective

The safety documentation for `Ptr::assert_unique` is incomplete.
Currently it only mentions the existence of other `Ptr` instances, but
it should also mention that the underlying data must be mutable and that
there cannot be active references to it.
This commit is contained in:
Joseph 2025-01-15 19:25:19 -08:00 committed by GitHub
parent 72f70745c5
commit 77fd7bf7ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -289,7 +289,9 @@ impl<'a, A: IsAligned> Ptr<'a, A> {
/// Transforms this [`Ptr`] into an [`PtrMut`]
///
/// # Safety
/// Another [`PtrMut`] for the same [`Ptr`] must not be created until the first is dropped.
/// * The data pointed to by this `Ptr` must be valid for writes.
/// * There must be no active references (mutable or otherwise) to the data underlying this `Ptr`.
/// * Another [`PtrMut`] for the same [`Ptr`] must not be created until the first is dropped.
#[inline]
pub unsafe fn assert_unique(self) -> PtrMut<'a, A> {
PtrMut(self.0, PhantomData)