Struct Cursor

Source
pub struct Cursor<'a, T> { /* private fields */ }
Expand description

Cursor over the tree elements.

If a move operation fails we Return a result with:

  • Ok: the moved cursor
  • Err: the previous unmodified cursor

Implementations§

Source§

impl<T> Cursor<'_, T>

Source

pub fn id(&self) -> NodeId

Source

pub fn get(&self) -> &T

Source

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

Source

pub fn parent(&mut self) -> Result<&mut Self, &mut Self>

Move the cursor to the parent

§Errors

If there is no next node will return the previous position

Source

pub fn first_child(&mut self) -> Result<&mut Self, &mut Self>

Move the cursor to the first child

§Errors

If there is no next node will return the previous position

Source

pub fn last_child(&mut self) -> Result<&mut Self, &mut Self>

Move the cursor to the last child

§Errors

If there is no next node will return the previous position

Source

pub fn next_sibling(&mut self) -> Result<&mut Self, &mut Self>

Move the cursor to the next sibling

§Errors

If there is no next node will return the previous position

Source

pub fn prev_sibling(&mut self) -> Result<&mut Self, &mut Self>

Move the cursor to the prev sibling

§Errors

If there is no next node will return the previous position

Source

pub fn move_next(&mut self) -> Result<&mut Self, &mut Self>

Move the cursor to the next node

§Errors

If there is no next node will return the previous position

Source

pub fn append_child(&mut self, value: T) -> NodeId

Source

pub fn append_sibling(&mut self, value: T) -> NodeId

Source

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

Source

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

Source

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

Source

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

Source

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

Trait Implementations§

Source§

impl<'a, T: Debug> Debug for Cursor<'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 Cursor<'a, T>

§

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

§

impl<'a, T> Send for Cursor<'a, T>
where T: Send,

§

impl<'a, T> Sync for Cursor<'a, T>
where T: Sync,

§

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

§

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