Struct NodeRef

Source
pub struct NodeRef<T> { /* private fields */ }
Expand description

Node reference.

Implementations§

Source§

impl<T> NodeRef<T>

Source

pub fn ancestors(&self) -> Ancestors<T>

Returns an iterator over ancestors.

Source

pub fn prev_siblings(&self) -> PrevSiblings<T>

Returns an iterator over previous siblings.

Source

pub fn next_siblings(&self) -> NextSiblings<T>

Returns an iterator over next siblings.

Source

pub fn first_children(&self) -> FirstChildren<T>

Returns an iterator over first children.

Source

pub fn last_children(&self) -> LastChildren<T>

Returns an iterator over last children.

Source

pub fn children(&self) -> Children<T>

Returns an iterator over children.

Source

pub fn traverse(&self) -> Traverse<T>

Returns an iterator which traverses the subtree starting at this node.

Source

pub fn descendants(&self) -> Descendants<T>

Returns an iterator over this node and its descendants.

Source§

impl<T> NodeRef<T>

Source

pub fn id(&self) -> NodeId

Returns the ID of this node.

Source

pub fn map_value<F, R>(&self, map_fn: F) -> Option<R>
where F: FnOnce(&T) -> R,

Returns the result of map_fn applied to the value of this node.

Source

pub fn update_value<F>(&self, update_fn: F) -> bool
where F: FnOnce(&mut T),

Update the value of this node.

Source

pub fn parent(&self) -> Option<Self>

Returns the parent of this node.

Source

pub fn prev_sibling(&self) -> Option<Self>

Returns the previous sibling of this node.

Source

pub fn next_sibling(&self) -> Option<Self>

Returns the next sibling of this node.

Source

pub fn first_child(&self) -> Option<Self>

Returns the first child of this node.

Source

pub fn last_child(&self) -> Option<Self>

Returns the last child of this node.

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 detach(&mut self)

Detaches this node from its parent.

Source

pub fn append(&mut self, value: T) -> Option<NodeRef<T>>

Appends a new child to this node.

Source

pub fn append_id(&mut self, new_child_id: NodeId) -> Option<NodeRef<T>>

Appends a child to this node.

Source

pub fn prepend(&mut self, value: T) -> Option<NodeRef<T>>

Prepends a new child to this node.

Source

pub fn insert_before(&mut self, value: T) -> Option<NodeRef<T>>

Inserts a new sibling before this node.

Source

pub fn insert_id_before(&mut self, new_sibling_id: NodeId) -> Option<NodeRef<T>>

Inserts a sibling before this node.

Source

pub fn insert_after(&mut self, value: T) -> Option<NodeRef<T>>

Inserts a new sibling after this node.

Source

pub fn insert_id_after(&mut self, new_sibling_id: NodeId) -> Option<NodeRef<T>>

Inserts a sibling after this node.

Source

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

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

Trait Implementations§

Source§

impl<T> Clone for NodeRef<T>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for NodeRef<T>

Source§

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

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

impl<T> PartialEq for NodeRef<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<T> Freeze for NodeRef<T>

§

impl<T> !RefUnwindSafe for NodeRef<T>

§

impl<T> !Send for NodeRef<T>

§

impl<T> !Sync for NodeRef<T>

§

impl<T> Unpin for NodeRef<T>

§

impl<T> !UnwindSafe for NodeRef<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.