From 9fc3603bf7203a5d4c6c00065a273cce1171b81b Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Wed, 18 Mar 2026 09:46:31 -0700 Subject: [PATCH] `fn DisjointImmutGuard::get_unchecked`: add `unsafe fn` to bypass `DisjointMut` --- src/disjoint_mut.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/disjoint_mut.rs b/src/disjoint_mut.rs index acc02d636..8c0a96abb 100644 --- a/src/disjoint_mut.rs +++ b/src/disjoint_mut.rs @@ -208,6 +208,18 @@ impl<'a, T: ?Sized + AsMutPtr, V: ?Sized> Deref for DisjointImmutGuard<'a, T, V> } } +impl<'a, T: ?Sized + AsMutPtr, V: ?Sized> DisjointImmutGuard<'a, T, V> { + // # Safety + // + // The slice of the [`DisjointMut`] this guard protects + // must not have overlapping mutable borrows. + // + // That is, this bypasses the disjoint mut check. + pub unsafe fn get_unchecked(&self) -> &'a V { + self.slice + } +} + /// Convert from a mutable pointer to a collection to a mutable pointer to the /// underlying slice without ever creating a mutable reference to the slice. ///