pub struct Path<B: Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> { /* private fields */ }
Expand description
A path to a [Tree] node A Path is a collection of branches to follow to get to the desired node. An empty Path represents the root of the [Tree].
§Examples
use nb_tree::prelude::{Tree, Path};
let mut tree = Tree::new();
// Paths from string litterals, vectors, or manually built
let path_d: Path<String> = "/b/d".into();
//let path_e: Path<String> = vec!["a", "c", "e"].into();
//let mut path_f = Path::new();
//path_f.l("b").l("f");
// Use paths to insert data
tree.i("/", 0)
.i("/a", 1)
.i("/b", 2)
.i("/a/c", 3)
.i(path_d, 4)
// .i(path_e, 5)
.i("/a/c/e", 5)
.i("/b/f", 6);
// .i(path_f, 6);
// Use paths to retrieve data
assert_eq!(tree.get(&"/a/c".into()), Ok(&3));
// Use paths to remove data
//tree.remove_sub_tree()
//assert
Implementations§
source§impl<B: Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Path<B>
impl<B: Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Path<B>
pub fn new() -> Self
pub fn pop_root(&mut self) -> Option<B>
pub fn pop_leaf(&mut self) -> Option<B>
pub fn push_leaf(&mut self, value: B)
pub fn push_root(&mut self, value: B)
pub fn last(&self) -> Option<&B>
pub fn first(&self) -> Option<&B>
pub fn iter(&self) -> Iter<'_, B>
Trait Implementations§
source§impl<B: Clone + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Clone for Path<B>
impl<B: Clone + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Clone for Path<B>
source§impl<B: Debug + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Debug for Path<B>
impl<B: Debug + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Debug for Path<B>
source§impl<B: Default + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Default for Path<B>
impl<B: Default + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Default for Path<B>
source§impl<B: Clone + Default + Display + PartialEq + Eq + PartialOrd + Ord + Hash> Display for Path<B>
impl<B: Clone + Default + Display + PartialEq + Eq + PartialOrd + Ord + Hash> Display for Path<B>
source§impl<B: Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash + FromStr> From<&str> for Path<B>
impl<B: Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash + FromStr> From<&str> for Path<B>
source§impl<B: Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> FromIterator<B> for Path<B>
impl<B: Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> FromIterator<B> for Path<B>
source§fn from_iter<T: IntoIterator<Item = B>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = B>>(iter: T) -> Self
Creates a value from an iterator. Read more
source§impl<B: Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash + FromStr> FromStr for Path<B>
impl<B: Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash + FromStr> FromStr for Path<B>
source§impl<B: Ord + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Ord for Path<B>
impl<B: Ord + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Ord for Path<B>
source§impl<B: PartialEq + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> PartialEq for Path<B>
impl<B: PartialEq + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> PartialEq for Path<B>
source§impl<B: PartialOrd + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> PartialOrd for Path<B>
impl<B: PartialOrd + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> PartialOrd for Path<B>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<B: Eq + Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> Eq for Path<B>
impl<B: Clone + Default + PartialEq + Eq + PartialOrd + Ord + Hash> StructuralPartialEq for Path<B>
Auto Trait Implementations§
impl<B> Freeze for Path<B>
impl<B> RefUnwindSafe for Path<B>where
B: RefUnwindSafe,
impl<B> Send for Path<B>where
B: Send,
impl<B> Sync for Path<B>where
B: Sync,
impl<B> Unpin for Path<B>where
B: Unpin,
impl<B> UnwindSafe for Path<B>where
B: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)