Struct DormantMutRef
pub(in ::collections::btree) struct DormantMutRef<'a, T> { pub(in ::collections::btree::borrow) ptr: NonNull<T>, pub(in ::collections::btree::borrow) _marker: PhantomData<&'a mut T> }
Models a reborrow of some unique reference, when you know that the reborrow and all its descendants (i.e., all pointers and references derived from it) will not be used any more at some point, after which you want to use the original unique reference again.
The borrow checker usually handles this stacking of borrows for you, but
some control flows that accomplish this stacking are too complicated for
the compiler to follow. A DormantMutRef allows you to check borrowing
yourself, while still expressing its stacked nature, and encapsulating
the raw pointer code needed to do this without undefined behavior.
Fields
ptr: NonNull<T>_marker: PhantomData<&'a mut T>
Implementations
impl<'a, T> DormantMutRef<'a, T>
fn new(t: &'a mut T) -> (&'a mut T, Self)Capture a unique borrow, and immediately reborrow it. For the compiler, the lifetime of the new reference is the same as the lifetime of the original reference, but you promise to use it for a shorter period.
unsafe fn awaken(self) -> &'a mut TRevert to the unique borrow initially captured.
Safety
The reborrow must have ended, i.e., the reference returned by
newand all pointers and references derived from it, must not be used anymore.unsafe fn reborrow(&mut self) -> &'a mut TBorrows a new mutable reference from the unique borrow initially captured.
Safety
The reborrow must have ended, i.e., the reference returned by
newand all pointers and references derived from it, must not be used anymore.Borrows a new shared reference from the unique borrow initially captured.
Safety
The reborrow must have ended, i.e., the reference returned by
newand all pointers and references derived from it, must not be used anymore.
Trait Implementations
impl<'a, T> Send for DormantMutRef<'a, T>
where
&'a mut T: Send,
impl<'a, T> Sync for DormantMutRef<'a, T>
where
&'a mut T: Sync,
Auto Trait Implementations
impl<'a, T> !UnwindSafe for DormantMutRef<'a, T>
impl<'a, T> Freeze for DormantMutRef<'a, T>
where
NonNull<T>: Freeze,
PhantomData<&'a mut T>: Freeze,
impl<'a, T> RefUnwindSafe for DormantMutRef<'a, T>
where
NonNull<T>: RefUnwindSafe,
PhantomData<&'a mut T>: RefUnwindSafe,
impl<'a, T> Unpin for DormantMutRef<'a, T>
where
NonNull<T>: Unpin,
PhantomData<&'a mut T>: Unpin,
impl<'a, T> UnsafeUnpin for DormantMutRef<'a, T>
where
NonNull<T>: UnsafeUnpin,
PhantomData<&'a mut T>: UnsafeUnpin,
Blanket Implementations
impl<T> Any for DormantMutRef<'a, T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for DormantMutRef<'a, T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for DormantMutRef<'a, T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for DormantMutRef<'a, T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for DormantMutRef<'a, T>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for DormantMutRef<'a, T>
impl<T, U> Into<U> for DormantMutRef<'a, T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for DormantMutRef<'a, T>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for DormantMutRef<'a, T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>