[−][src]Struct id_tree::NodeBuilder
A Node
builder that provides more control over how a Node
is created.
Methods
impl<T> NodeBuilder<T>
[src]
pub fn new(data: T) -> NodeBuilder<T>
[src]
Creates a new NodeBuilder
with the required data.
use id_tree::NodeBuilder; let _node_builder = NodeBuilder::new(5);
pub fn with_child_capacity(self, child_capacity: usize) -> NodeBuilder<T>
[src]
Set the child capacity of the NodeBuilder
.
As Node
s are added to a Tree
, parent and child references must be maintained. To do
this, an allocation must be made every time a child is added to a Node
. Using this
setting allows the Node
to pre-allocate space for its children so that the allocations
aren't made as children are added.
Use of this setting is recommended if you know the maximum number of children (not
including grandchildren, great-grandchildren, etc.) that a Node
will have at any given
time.
use id_tree::NodeBuilder; let _node_builder = NodeBuilder::new(5).with_child_capacity(3);
pub fn build(self) -> Node<T>
[src]
Build a Node
based upon the current settings in the NodeBuilder
.
use id_tree::NodeBuilder; use id_tree::Node; let node: Node<i32> = NodeBuilder::new(5) .with_child_capacity(3) .build(); assert_eq!(node.data(), &5); assert_eq!(node.children().capacity(), 3);
Auto Trait Implementations
impl<T> Send for NodeBuilder<T> where
T: Send,
T: Send,
impl<T> Sync for NodeBuilder<T> where
T: Sync,
T: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,