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 118)
102fn node_list(
103 depth: usize,
104 directory: &PathBuf,
105) -> Result<NodeList<FileBackend, Arc<PathBuf>, io::Error, PathBuf, Metadata>, io::Error> {
106 let mut list = NodeList::default();
107
108 for entry in read_dir(directory)? {
109 let entry = entry?;
110
111 let kind = if entry.file_type()?.is_dir() { NodeKind::Branch } else { NodeKind::Leaf };
112
113 let file_name = entry.file_name();
114 let file_name = file_name.to_string_lossy();
115
116 // We'll use different styles for leaves and branches
117 let mut representation = Representation::default();
118 if kind.is_branch() {
119 representation.append_styled(file_name, Style::title_primary());
120 } else {
121 representation.append_styled(file_name, Style::title_secondary());
122 }
123
124 list.add(depth, kind, entry.path(), representation);
125 }
126
127 Ok(list)
128}Trait Implementations§
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