pub struct RefMutStack<'a, R, T> { /* private fields */ }Expand description
The stack of mutable references and their holders.
It allows to simulate recursion where each level holds a mutable reference to the one held by the caller with an iteration.
It is made in such a way that the rules enforced by the borrow checker during the theoretical recursion are still enforced during iterations. On that purpose, each object holding a mutable reference becomes unreachable when the recursion is simulated: it is stacked until it becomes usable again.
In order to use it:
- create a new stack with the root mutable reference using
RefMutStack::new - call
RefMutStack::borrow_mutto create the root holder of typeT - enable recursion in
Titself by callingParkableRefMut::parkerand park the holder withParker::park - finish recursion by calling
ParkableRefMut::unpark
See builder examples in tests for more details.
Implementations§
Source§impl<'a, R, T> RefMutStack<'a, R, T>
impl<'a, R, T> RefMutStack<'a, R, T>
Sourcepub fn borrow_mut(&'a mut self) -> ParkableRefMut<'a, R, T>
pub fn borrow_mut(&'a mut self) -> ParkableRefMut<'a, R, T>
Borrows the current mutable reference at the top of the stack in order to use it.
Auto Trait Implementations§
impl<'a, R, T> Freeze for RefMutStack<'a, R, T>
impl<'a, R, T> RefUnwindSafe for RefMutStack<'a, R, T>where
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, R, T> !Send for RefMutStack<'a, R, T>
impl<'a, R, T> !Sync for RefMutStack<'a, R, T>
impl<'a, R, T> Unpin for RefMutStack<'a, R, T>where
T: Unpin,
impl<'a, R, T> UnsafeUnpin for RefMutStack<'a, R, T>
impl<'a, R, T> UnwindSafe for RefMutStack<'a, R, T>where
R: RefUnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more