pub enum NodeKind {
Branch,
Leaf,
}Expand description
Tree node kind.
Variants§
Implementations§
Source§impl NodeKind
impl NodeKind
Sourcepub fn is_branch(&self) -> bool
pub fn is_branch(&self) -> bool
Whether the node is a branch.
Examples found in repository?
examples/file_browser.rs (line 111)
100fn node_list(depth: usize, directory: &PathBuf) -> Result<NodeList<FileBackend>, io::Error> {
101 let mut list = NodeList::default();
102
103 for entry in read_dir(directory)? {
104 let entry = entry?;
105 let kind = if entry.file_type()?.is_dir() { NodeKind::Branch } else { NodeKind::Leaf };
106 let path = entry.path();
107 let file_name = entry.file_name();
108 let file_name = file_name.to_string_lossy();
109
110 // We'll use different label styles for leaves and branches
111 if kind.is_branch() {
112 let mut file_name_ = SpannedString::default();
113 file_name_.append_styled(file_name, Style::primary().combine(Effect::Bold));
114 list.add(depth, kind, path, file_name_);
115 } else {
116 list.add(depth, kind, path, file_name);
117 }
118 }
119
120 list.0.sort_by(|a: &Node<FileBackend>, b: &Node<FileBackend>| a.id.cmp(&b.id));
121
122 Ok(list)
123}Trait Implementations§
impl Copy for NodeKind
impl Eq for NodeKind
impl StructuralPartialEq for NodeKind
Auto Trait Implementations§
impl Freeze for NodeKind
impl RefUnwindSafe for NodeKind
impl Send for NodeKind
impl Sync for NodeKind
impl Unpin for NodeKind
impl UnsafeUnpin for NodeKind
impl UnwindSafe for NodeKind
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