Trait HasChildrenMut

Source
pub trait HasChildrenMut<'a, T>: HasChildren<'a, T> {
    // Required methods
    fn children_mut(&mut self) -> NodeChildrenMut<'a, '_, T>;
    fn set_children<I>(&mut self, iterable: I)
       where I: IntoIterator<Item = T>;
    fn set_children_subtree<I, F, U>(&mut self, iterable: I, builder: F)
       where I: IntoIterator<Item = (T, U)>,
             F: FnMut(NodeMut<'a, '_, T>, U);
    fn adopt_grandchildren_at(&mut self, index: usize);
    fn move_children_to_root(&mut self);
    fn iter_mut(&mut self) -> NodeIterMut<'a, '_, T> ;
    fn at_mut(&mut self, index: usize) -> NodeMut<'a, '_, T>;
}
Expand description

A trait for types that have mutable child nodes.

This trait primarily exists for documentation purposes. Consider calling children_mut before writing generic code over this trait.

Required Methods§

Source

fn children_mut(&mut self) -> NodeChildrenMut<'a, '_, T>

Returns a mutable reference to the child nodes.

Source

fn set_children<I>(&mut self, iterable: I)
where I: IntoIterator<Item = T>,

Sets the child nodes using the provided iterable.

This function allocates a slice of new nodes for each item in the iterable and replaces the current children with these new nodes. Any previous child nodes become inaccessible.

Source

fn set_children_subtree<I, F, U>(&mut self, iterable: I, builder: F)
where I: IntoIterator<Item = (T, U)>, F: FnMut(NodeMut<'a, '_, T>, U),

Sets the child nodes using the provided iterable, allowing recursive construction of a subtree.

This function allocates a slice of new nodes for each item in the iterable and replaces the current children with these new nodes. The builder function is called for each element during iteration, allowing further children to be created recursively. Any previous child nodes become inaccessible.

Source

fn adopt_grandchildren_at(&mut self, index: usize)

Adopts the children of the child node at the given index as the children here.

This replaces the current children with one set of grandchildren. Any previous child nodes and the other sets of grandchildren and their descendents become inaccessible.

Source

fn move_children_to_root(&mut self)

Moves the child nodes from here to become the roots of the tree.

This replaces the current children of the node with an empty slice, unless this is already the root.

Source

fn iter_mut(&mut self) -> NodeIterMut<'a, '_, T>

Returns an iterator over mutable references to the child nodes.

Source

fn at_mut(&mut self, index: usize) -> NodeMut<'a, '_, T>

Returns a mutable reference to the child node at the given index.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, T> HasChildrenMut<'a, T> for NodeChildrenMut<'a, '_, T>

Source§

impl<'a, T> HasChildrenMut<'a, T> for NodeMut<'a, '_, T>

Source§

impl<'a, T> HasChildrenMut<'a, T> for SlidingTree<'a, T>