pub struct Tree<T> {
pub item: T,
pub children: Vec<Tree<T>>,
}
Fields§
§item: T
§children: Vec<Tree<T>>
Implementations§
Source§impl<T> Tree<T>
impl<T> Tree<T>
pub fn new(item: T, children: Vec<Tree<T>>) -> Tree<T>
pub fn singleton(item: T) -> Tree<T>
Sourcepub fn lookup(&self, path: Path) -> Option<&T>
pub fn lookup(&self, path: Path) -> Option<&T>
Lookup the item in the Tree
that corresponds to the given Path
.
Sourcepub fn path_map_map<U>(&self, f: &dyn Fn(&T) -> U) -> TreePathMap<U>
pub fn path_map_map<U>(&self, f: &dyn Fn(&T) -> U) -> TreePathMap<U>
Similar to path_map
, but take a function for mapping an item in the tree to an
alternative type to use to construct the TreePathMap
.
This is useful when there is some information in the item for the Tree
that
can be thrown away when constructing the TreePathMap
.
Trait Implementations§
impl<T: Eq> Eq for Tree<T>
impl<T> StructuralPartialEq for Tree<T>
Auto Trait Implementations§
impl<T> Freeze for Tree<T>where
T: Freeze,
impl<T> RefUnwindSafe for Tree<T>where
T: RefUnwindSafe,
impl<T> Send for Tree<T>where
T: Send,
impl<T> Sync for Tree<T>where
T: Sync,
impl<T> Unpin for Tree<T>where
T: Unpin,
impl<T> UnwindSafe for Tree<T>where
T: 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