pub struct PathTree<T>(/* private fields */);Expand description
A tree data structure for storing paths without mutation.
Cloning the data structure is inexpensive since each clone only clones a single Arc.
§Examples
use pathtree::PathTree;
let path = PathTree::empty();
let path = path.append_segment(7);
let path = path.append_segment(5);
let path = path.prepend_segment(6);
let path = path.prepend_segment(8);
let path_vec: Vec<_> = path.iter().copied().collect();
assert_eq!(path_vec, vec![8, 6, 7, 5]);
let other_path = PathTree::empty();
let other_path = other_path.append_segment(2);
let other_path = other_path.prepend_segment(1);
let other_path = other_path.append_segment(3);
let other_path = other_path.prepend_segment(4);
let full_path = other_path.append(&path);
let full_path_vec: Vec<_> = full_path.iter().copied().collect();
assert_eq!(full_path_vec, vec![4, 1, 2, 3, 8, 6, 7, 5]);Implementations§
Source§impl<T> PathTree<T>
impl<T> PathTree<T>
Sourcepub fn append_segment(&self, segment: T) -> Self
pub fn append_segment(&self, segment: T) -> Self
Appends a segment to self.
Sourcepub fn prepend_segment(&self, segment: T) -> Self
pub fn prepend_segment(&self, segment: T) -> Self
Prepends a segment to self.
Trait Implementations§
Source§impl<A> FromIterator<A> for PathTree<A>
impl<A> FromIterator<A> for PathTree<A>
Source§fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self
Creates a value from an iterator. Read more
Source§impl<'a, T> IntoIterator for &'a PathTree<T>
impl<'a, T> IntoIterator for &'a PathTree<T>
Source§impl<T: Ord> Ord for PathTree<T>
impl<T: Ord> Ord for PathTree<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for PathTree<T>
impl<T: PartialOrd> PartialOrd for PathTree<T>
impl<T: Eq> Eq for PathTree<T>
impl<T> StructuralPartialEq for PathTree<T>
Auto Trait Implementations§
impl<T> Freeze for PathTree<T>
impl<T> RefUnwindSafe for PathTree<T>where
T: RefUnwindSafe,
impl<T> Send for PathTree<T>
impl<T> Sync for PathTree<T>
impl<T> Unpin for PathTree<T>
impl<T> UnwindSafe for PathTree<T>where
T: RefUnwindSafe,
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