Skip to main content

RefMutStack

Struct RefMutStack 

Source
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:

See builder examples in tests for more details.

Implementations§

Source§

impl<'a, R, T> RefMutStack<'a, R, T>

Source

pub fn new(r: &'a mut R) -> Self

Creates a new stack with the root mutable reference.

Source

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>

§

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>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.