diff --git a/src/disjoint_mut.rs b/src/disjoint_mut.rs index 7a8dc471c..12a4adf9f 100644 --- a/src/disjoint_mut.rs +++ b/src/disjoint_mut.rs @@ -48,6 +48,16 @@ pub struct DisjointMut { inner: UnsafeCell, } +impl DisjointMut { + pub const fn new(value: T) -> Self { + Self { + inner: UnsafeCell::new(value), + #[cfg(debug_assertions)] + bounds: debug::DisjointMutAllBounds::new(), + } + } +} + #[cfg_attr(not(debug_assertions), repr(transparent))] pub struct DisjointMutGuard<'a, T: ?Sized + AsMutPtr, V: ?Sized> { slice: &'a mut V, @@ -443,6 +453,15 @@ mod debug { immutable: Mutex>, } + impl DisjointMutAllBounds { + pub const fn new() -> Self { + Self { + mutable: Mutex::new(Vec::new()), + immutable: Mutex::new(Vec::new()), + } + } + } + // Inline so that the thread doesn't switch during this call, // which seems to happen (the backtrace ends in this call). #[inline(always)]