Struct TreeCursorMut

Source
pub struct TreeCursorMut<'n: 'f, 'f, N: 'n> { /* private fields */ }
Expand description

A cursor that holds a mutable reference to its tree.

Implementations§

Source§

impl<'n, N: 'n> TreeCursorMut<'n, 'n, N>

Source

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

Creates a new TreeCursorMut starting at root.

Source§

impl<'n: 'f, 'f, N: 'n> TreeCursorMut<'n, 'f, N>

Source

pub fn down_map<F>(&mut self, f: F) -> bool

Passes f the active node and the current value of the “next child” counter. If f returns a node, it’s set as the active node, the old active node’s “next child” counter is incremented, and this method returns true. Otherwise, this method returns false.

Source

pub fn down_map_new<'s, F>( &'s mut self, f: F, ) -> Option<TreeCursorMut<'n, 's, N>>

Like down_new, except that it takes a closure like down_map.

Source

pub fn zero(&mut self)

Resets the active node’s “next child” counter to 0.

Source

pub fn up(&mut self) -> bool

Moves the cursor up one node. Returns true if there was a node to move to, and false otherwise. In both cases, the old active node’s “next child” counter is reset, as if zero had been called.

Source

pub fn take<'s>(&'s mut self) -> Option<TreeCursorMut<'n, 's, N>>

Takes the active node from this TreeCursorMut and returns a new TreeCursorMut at that position. self is frozen until the new cursor goes out of scope.

Source

pub fn get(&self) -> &N

Returns a shared reference to the active node.

Source

pub fn get_mut(&mut self) -> &mut N

Returns a mutable reference to the active node.

Source

pub fn as_cursor<'s>(&'s self) -> TreeCursor<'n, 's, N>

Source§

impl<'n: 'f, 'f, N: 'n + DownMut> TreeCursorMut<'n, 'f, N>

Source

pub fn pos(&self) -> TreeCursorPos

Returns an opaque object that stores the current position of the cursor. Pass it to set_pos to restore that position.

Source

pub fn set_pos(&mut self, pos: &TreeCursorPos)

Moves the cursor to the given position, as long as tree mutation hasn’t invalidated the position since it was retrieved.

§Panics

If the tree has changed such that the position is no longer valid, this method panics. However, since the position is stored using “next child” indices (not pointers), it remains valid as long as the tree has a node in that position, even if the node’s value changes or it’s replaced with another node. If this is a problem, you should track the position’s validity yourself.

Source

pub fn down(&mut self) -> bool

Moves the cursor down one node. The node to move to is determined by calling DownMut::down_mut on the active node and passing it the “next child” counter. Returns true and increments the old active node’s “next child” counter if there was a node to move to, and returns false otherwise.

Source

pub fn down_new<'s>(&'s mut self) -> Option<TreeCursorMut<'n, 's, N>>

Like down, except instead of moving the position of self, it returns a new TreeCursorMut whose root is the new position. self is frozen until the new cursor goes out of scope.

Trait Implementations§

Source§

impl<'n: 'f, 'f, N: Debug + 'n> Debug for TreeCursorMut<'n, 'f, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'n: 'f, 'f, N: 'n> From<TreeCursorMut<'n, 'f, N>> for TreeCursor<'n, 'f, N>

Source§

fn from(cm: TreeCursorMut<'n, 'f, N>) -> Self

Converts to this type from the input type.
Source§

impl<'n: 'f, 'f, N: Hash + 'n> Hash for TreeCursorMut<'n, 'f, N>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'n: 'f, 'f, N: PartialEq + 'n> PartialEq for TreeCursorMut<'n, 'f, N>

Source§

fn eq(&self, other: &TreeCursorMut<'n, 'f, N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'n: 'f, 'f, N: Eq + 'n> Eq for TreeCursorMut<'n, 'f, N>

Source§

impl<'n: 'f, 'f, N: 'n> StructuralPartialEq for TreeCursorMut<'n, 'f, N>

Auto Trait Implementations§

§

impl<'n, 'f, N> Freeze for TreeCursorMut<'n, 'f, N>

§

impl<'n, 'f, N> RefUnwindSafe for TreeCursorMut<'n, 'f, N>
where N: RefUnwindSafe,

§

impl<'n, 'f, N> !Send for TreeCursorMut<'n, 'f, N>

§

impl<'n, 'f, N> !Sync for TreeCursorMut<'n, 'f, N>

§

impl<'n, 'f, N> Unpin for TreeCursorMut<'n, 'f, N>

§

impl<'n, 'f, N> !UnwindSafe for TreeCursorMut<'n, 'f, N>

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.