pub struct Builder { /* private fields */ }
Expand description
Create a FlatTree using simple commands A flat tree itself is immutable, so we use the builder pattern.
§Example
use flange_flat_tree::navigator::Builder;
// A navigator just stores neigbors, so we provide no values
let mut b = Builder::default();
let root = b.start_element();
let child = b.start_end_element();
let nav = b.build();
assert_eq!(nav.children(root), [child]);
assert_eq!(nav.parent(child), Some(root));
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn with_capacity(c: usize) -> Builder
pub fn with_capacity(c: usize) -> Builder
Create a new builder and pre-allocate memory
Sourcepub fn start_element(&mut self) -> usize
pub fn start_element(&mut self) -> usize
Start a new element.
This element will be the child of the last element
that was not finished with end_element
.
Sourcepub fn end_element(&mut self) -> usize
pub fn end_element(&mut self) -> usize
End and element.
No more children will be added to this element. The next element would be a sibling of this element.
Sourcepub fn start_end_element(&mut self) -> usize
pub fn start_end_element(&mut self) -> usize
Start and imidiatly end an element.
This is the same as calling start_element
and end_element
after each other.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more