Struct CursorMut

Source
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

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>

Source

pub fn subtree(&self) -> &SyntaxTree<T>

Gets a syntax tree where the root is the current node.

Source

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.

Source

pub fn split_next(&mut self) -> Option<NonNull<Node<T>>>

Splits the tree at the current element.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn move_next(&mut self)

Moves the cursor to the next element.

Source

pub fn move_child(&mut self)

Moves the cursor to the child element.

Source

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.

Source

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.

Source

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.

Source

pub fn peek_next(&self) -> Option<&T>

Returns a reference to the next element.

Source

pub fn peek_parent(&self) -> Option<&T>

Returns a reference to the parent element.

Wrapper around self.peek_preceding().and_then(Preceding::parent).

Source

pub fn peek_previous(&self) -> Option<&T>

Returns a reference to the previous element.

Wrapper around self.peek_preceding().and_then(Preceding::previous) .

Source

pub fn peek_preceding(&self) -> Option<Preceding<&T>>

Returns a reference to the preceding element.

Source

pub fn peek_child(&self) -> Option<&T>

Returns a reference to the child element.

Source

pub fn current_mut(&mut self) -> Option<&mut T>

Get the current element.

Source

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.

Source

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.

Source

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.

Source

pub fn remove_current(&mut self)

Removes the current node.

When removing a node with a child node, the child node is removed.

Source

pub fn flatten(&self)

Moves the children of the current element to next elements.

Trait Implementations§

Source§

impl<'a, T: Debug> Debug for CursorMut<'a, T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for CursorMut<'a, T>

§

impl<'a, T> RefUnwindSafe for CursorMut<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Send for CursorMut<'a, T>

§

impl<'a, T> !Sync for CursorMut<'a, T>

§

impl<'a, T> Unpin for CursorMut<'a, T>

§

impl<'a, T> !UnwindSafe for CursorMut<'a, 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.