Struct ego_tree::NodeMut

source ·
pub struct NodeMut<'a, T: 'a> { /* private fields */ }
Expand description

Node mutator.

Implementations§

source§

impl<'a, T: 'a> NodeMut<'a, T>

source

pub fn id(&self) -> NodeId

Returns the ID of this node.

source

pub fn tree(&mut self) -> &mut Tree<T>

Returns the tree owning this node.

source

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

Returns the value of this node.

source

pub fn parent(&mut self) -> Option<NodeMut<'_, T>>

Returns the parent of this node.

source

pub fn into_parent(self) -> Result<Self, Self>

Returns the parent of this node.

Returns Ok(parent) if possible and Err(self) otherwise so the caller can recover the current position.

source

pub fn prev_sibling(&mut self) -> Option<NodeMut<'_, T>>

Returns the previous sibling of this node.

source

pub fn into_prev_sibling(self) -> Result<Self, Self>

Returns the previous sibling of this node.

Returns Ok(prev_sibling) if possible and Err(self) otherwise so the caller can recover the current position.

source

pub fn next_sibling(&mut self) -> Option<NodeMut<'_, T>>

Returns the next sibling of this node.

source

pub fn into_next_sibling(self) -> Result<Self, Self>

Returns the next sibling of this node.

Returns Ok(next_sibling) if possible and Err(self) otherwise so the caller can recover the current position.

source

pub fn first_child(&mut self) -> Option<NodeMut<'_, T>>

Returns the first child of this node.

source

pub fn into_first_child(self) -> Result<Self, Self>

Returns the first child of this node.

Returns Ok(first_child) if possible and Err(self) otherwise so the caller can recover the current position.

source

pub fn last_child(&mut self) -> Option<NodeMut<'_, T>>

Returns the last child of this node.

source

pub fn into_last_child(self) -> Result<Self, Self>

Returns the last child of this node.

Returns Ok(last_child) if possible and Err(self) otherwise so the caller can recover the current position.

source

pub fn has_siblings(&self) -> bool

Returns true if this node has siblings.

source

pub fn has_children(&self) -> bool

Returns true if this node has children.

source

pub fn append(&mut self, value: T) -> NodeMut<'_, T>

Appends a new child to this node.

source

pub fn prepend(&mut self, value: T) -> NodeMut<'_, T>

Prepends a new child to this node.

source

pub fn append_subtree(&mut self, subtree: Tree<T>) -> NodeMut<'_, T>

Appends a subtree, return the root of the merged subtree.

source

pub fn prepend_subtree(&mut self, subtree: Tree<T>) -> NodeMut<'_, T>

Prepends a subtree, return the root of the merged subtree.

source

pub fn insert_before(&mut self, value: T) -> NodeMut<'_, T>

Inserts a new sibling before this node.

§Panics

Panics if this node is an orphan.

source

pub fn insert_after(&mut self, value: T) -> NodeMut<'_, T>

Inserts a new sibling after this node.

§Panics

Panics if this node is an orphan.

source

pub fn detach(&mut self)

Detaches this node from its parent.

source

pub fn append_id(&mut self, new_child_id: NodeId) -> NodeMut<'_, T>

Appends a child to this node.

§Panics

Panics if new_child_id is not valid.

source

pub fn prepend_id(&mut self, new_child_id: NodeId) -> NodeMut<'_, T>

Prepends a child to this node.

§Panics

Panics if new_child_id is not valid.

source

pub fn insert_id_before(&mut self, new_sibling_id: NodeId) -> NodeMut<'_, T>

Inserts a sibling before this node.

§Panics
  • Panics if new_sibling_id is not valid.
  • Panics if this node is an orphan.
source

pub fn insert_id_after(&mut self, new_sibling_id: NodeId) -> NodeMut<'_, T>

Inserts a sibling after this node.

§Panics
  • Panics if new_sibling_id is not valid.
  • Panics if this node is an orphan.
source

pub fn reparent_from_id_append(&mut self, from_id: NodeId)

Reparents the children of a node, appending them to this node.

§Panics

Panics if from_id is not valid.

source

pub fn reparent_from_id_prepend(&mut self, from_id: NodeId)

Reparents the children of a node, prepending them to this node.

§Panics

Panics if from_id is not valid.

Trait Implementations§

source§

impl<'a, T: Debug + 'a> Debug for NodeMut<'a, T>

source§

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

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

impl<'a, T: 'a> From<NodeMut<'a, T>> for NodeRef<'a, T>

source§

fn from(node: NodeMut<'a, T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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