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>
impl<'n, N: 'n> TreeCursorMut<'n, 'n, N>
Source§impl<'n: 'f, 'f, N: 'n> TreeCursorMut<'n, 'f, N>
impl<'n: 'f, 'f, N: 'n> TreeCursorMut<'n, 'f, N>
Sourcepub fn down_map<F>(&mut self, f: F) -> bool
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.
Sourcepub fn down_map_new<'s, F>(
&'s mut self,
f: F,
) -> Option<TreeCursorMut<'n, 's, N>>
pub fn down_map_new<'s, F>( &'s mut self, f: F, ) -> Option<TreeCursorMut<'n, 's, N>>
Sourcepub fn up(&mut self) -> bool
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.
Sourcepub fn take<'s>(&'s mut self) -> Option<TreeCursorMut<'n, 's, N>>
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.
pub fn as_cursor<'s>(&'s self) -> TreeCursor<'n, 's, N>
Source§impl<'n: 'f, 'f, N: 'n + DownMut> TreeCursorMut<'n, 'f, N>
impl<'n: 'f, 'f, N: 'n + DownMut> TreeCursorMut<'n, 'f, N>
Sourcepub fn pos(&self) -> TreeCursorPos
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.
Sourcepub fn set_pos(&mut self, pos: &TreeCursorPos)
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.
Sourcepub fn down(&mut self) -> bool
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.
Sourcepub fn down_new<'s>(&'s mut self) -> Option<TreeCursorMut<'n, 's, N>>
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.