pub struct CursorMut<'a, T> {
pub preceding: Option<Preceding<NonNull<Node<T>>>>,
pub current: Option<NonNull<Node<T>>>,
pub root: &'a mut Option<NonNull<Node<T>>>,
}
Expand description
Roughly matches std::collections::linked_list::CursorMut
.
Fields§
§preceding: Option<Preceding<NonNull<Node<T>>>>
The preceding element, mutably accessing this is unsafe.
current: Option<NonNull<Node<T>>>
The current element, mutably accessing this is unsafe.
root: &'a mut Option<NonNull<Node<T>>>
This can also be a bound where self.current
can be equal to self.root
but it cannot be moved before this.
Implementations§
Source§impl<'a, T> CursorMut<'a, T>
impl<'a, T> CursorMut<'a, T>
Sourcepub fn subtree(&self) -> &SyntaxTree<T>
pub fn subtree(&self) -> &SyntaxTree<T>
Gets a syntax tree where the root is the current node.
Sourcepub fn split_restricted(
&mut self,
) -> (CursorMut<'_, T>, RestrictedCursor<'_, T>)
pub fn split_restricted( &mut self, ) -> (CursorMut<'_, T>, RestrictedCursor<'_, T>)
Splits the cursor at the current element, where the returned mutable cursor points to the current element and the return immutable cursor points to the preceding element.
Sourcepub fn split_next(&mut self) -> Option<NonNull<Node<T>>>
pub fn split_next(&mut self) -> Option<NonNull<Node<T>>>
Splits the tree at the current element.
Sourcepub fn split(&mut self) -> (CursorMut<'_, T>, Cursor<'_, T>)
pub fn split(&mut self) -> (CursorMut<'_, T>, Cursor<'_, T>)
Splits the cursor at the current element, where the returned mutable cursor points to the current element and the return immutable cursor points to the preceding element.
Sourcepub fn current(&self) -> Option<&T>
pub fn current(&self) -> Option<&T>
Get the current element.
Returns None
if the current element is None
or if the current element is the lower bound.
Sourcepub fn peek_move_preceding(&mut self) -> Option<&T>
pub fn peek_move_preceding(&mut self) -> Option<&T>
Moves the cursor to the preceding element returning a reference to the new element if one is present, otherwise returning None
.
Sourcepub fn move_preceding(&mut self) -> bool
pub fn move_preceding(&mut self) -> bool
Moves the cursor to the preceding element.
If there is no preceding element or the cursor is at its preceding_bound
it doesn’t move.
Sourcepub fn move_child(&mut self)
pub fn move_child(&mut self)
Moves the cursor to the child element.
Sourcepub fn move_parent(&mut self) -> bool
pub fn move_parent(&mut self) -> bool
Moves the cursor through preceding elements until reaching a parent, if no parent is found, the cursor is reset to its original position.
Returns true
if the cursor was moved to a parent, or false
if not.
Sourcepub fn move_successor(&mut self) -> bool
pub fn move_successor(&mut self) -> bool
Moves the cursor to the successor element if one can be found. If there is no successor element the cursor is reset to its original position and is not moved.
Returns true
if the cursor was moved to a successor, or false
if not.
Sourcepub fn move_predecessor(&mut self) -> bool
pub fn move_predecessor(&mut self) -> bool
Moves the cursor to the predecessor element if one can be found. If there is no predecessor element the cursor is reset to its original position and is not moved.
Returns true
if the cursor was moved to a predecessor, or false
if not.
Sourcepub fn peek_parent(&self) -> Option<&T>
pub fn peek_parent(&self) -> Option<&T>
Returns a reference to the parent element.
Wrapper around self.peek_preceding().and_then(Preceding::parent)
.
Sourcepub fn peek_previous(&self) -> Option<&T>
pub fn peek_previous(&self) -> Option<&T>
Returns a reference to the previous element.
Wrapper around self.peek_preceding().and_then(Preceding::previous)
.
Sourcepub fn peek_preceding(&self) -> Option<Preceding<&T>>
pub fn peek_preceding(&self) -> Option<Preceding<&T>>
Returns a reference to the preceding element.
Sourcepub fn peek_child(&self) -> Option<&T>
pub fn peek_child(&self) -> Option<&T>
Returns a reference to the child element.
Sourcepub fn current_mut(&mut self) -> Option<&mut T>
pub fn current_mut(&mut self) -> Option<&mut T>
Get the current element.
Sourcepub fn insert_preceding(&mut self, item: T)
pub fn insert_preceding(&mut self, item: T)
Inserts an element before the current element.
If the cursor has None
current element it is set to the inserted element.
Sourcepub fn insert_next(&mut self, item: T)
pub fn insert_next(&mut self, item: T)
Inserts an element after the current element.
If the cursor has None
current element it is set to the inserted element.
Sourcepub fn insert_child(&mut self, item: T)
pub fn insert_child(&mut self, item: T)
Inserts an element as a child of the current element.
If the cursor has None
current element it is set to the inserted element.
Sourcepub fn remove_current(&mut self)
pub fn remove_current(&mut self)
Removes the current node.
When removing a node with a child node, the child node is removed.