Struct MutCursorVec

Source
pub struct MutCursorVec<'root, T: ?Sized + 'root> { /* private fields */ }
Available on crate feature alloc only.
Expand description

Similar to MutCursor, but allows for a dynamically growing stack

MutCursorVec is not available if the alloc feature is disabled. (The feature is enabled by default.)

Implementations§

Source§

impl<'root, T: ?Sized + 'root> MutCursorVec<'root, T>

Source

pub fn new(root: &'root mut T) -> Self

Returns a new MutCursorVec with a reference to the specified root

Source

pub fn new_with_capacity(root: &'root mut T, capacity: usize) -> Self

Returns a new MutCursorVec with a reference to the specified root, and an allocated buffer for capacity references

Source

pub fn top(&self) -> &T

Returns a const reference from the mutable reference on the top of the stack

Source

pub fn top_mut(&mut self) -> &mut T

Returns the mutable reference on the top of the stack

Source

pub fn into_mut(self) -> &'root mut T

Returns the mutable reference on the top of the stack, consuming the stack

Source

pub fn try_map_into_mut<U, E, F>(self, f: F) -> Result<&'root mut U, (Self, E)>
where for<'r> F: FnOnce(&'r mut T) -> Result<&'r mut U, E>,

Consumes the stack and returns a mutable reference to an object with the 'root lifetime, if a closure returns Ok, otherwise returns the stack and a custom error value

NOTE: Usage is identical to MutCursor::try_map_into_mut

Source

pub fn depth(&self) -> usize

Returns the number of excess references stored in the stack, which corresponds to the number of times backtrack may be called

Source

pub fn capacity(&self) -> usize

Returns the number of references the stack is capable of holding without reallocation

Source

pub fn advance<F>(&mut self, step_f: F) -> bool
where F: FnOnce(&mut T) -> Option<&mut T>,

Steps deeper into the traversal, pushing a new reference onto the top of the stack

If the step_f closure returns Some(), the contained reference is pushed onto the stack and this method returns true. If the closure returns None then the stack is unmodified and this method returns false.

Source

pub fn backtrack(&mut self)

Pops a reference from the stack, exposing the prior reference as the new top

This method will panic if the stack contains only 1 entry

Source

pub fn to_root(&mut self)

Pops all references from the stack, exposing the root reference as the top

This method does nothing if the stack is already at the root

Trait Implementations§

Source§

impl<'root, T: ?Sized> Deref for MutCursorVec<'root, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<'root, T: ?Sized> DerefMut for MutCursorVec<'root, T>

Source§

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

Mutably dereferences the value.
Source§

impl<'a, T> Send for MutCursorVec<'a, T>
where T: Send + ?Sized,

Source§

impl<'a, T> Sync for MutCursorVec<'a, T>
where T: Sync + ?Sized,

Auto Trait Implementations§

§

impl<'root, T> Freeze for MutCursorVec<'root, T>
where T: ?Sized,

§

impl<'root, T> RefUnwindSafe for MutCursorVec<'root, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'root, T> Unpin for MutCursorVec<'root, T>
where T: ?Sized,

§

impl<'root, T> !UnwindSafe for MutCursorVec<'root, 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.