mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Cleanup (#121)
* remove unneeded identity .map()
* remove redunant field name in struct
* impl num_siblings for Node
* replace nested if w/ match in get_tree_chars
* remove unneeded field name in struct
* remove redundant println! & logic in display_node
* make get_children_from_node a Node method
* Revert "remove redundant println! & logic in display_node"
This reverts commit 40777025d5.
This commit is contained in:
+17
-1
@@ -17,7 +17,7 @@ use self::platform::*;
|
||||
|
||||
type PathData = (PathBuf, u64, Option<(u64, u64)>);
|
||||
|
||||
#[derive(Debug, Default, Eq)]
|
||||
#[derive(Debug, Default, Eq, Clone)]
|
||||
pub struct Node {
|
||||
pub name: PathBuf,
|
||||
pub size: u64,
|
||||
@@ -46,6 +46,22 @@ impl PartialEq for Node {
|
||||
}
|
||||
}
|
||||
|
||||
impl Node {
|
||||
pub fn num_siblings(&self) -> u64 {
|
||||
self.children.len() as u64
|
||||
}
|
||||
|
||||
pub fn get_children_from_node(&self, is_reversed: bool) -> impl Iterator<Item = Node> {
|
||||
let children = self.children.clone();
|
||||
if is_reversed {
|
||||
let children: Vec<Node> = children.into_iter().rev().collect();
|
||||
return children.into_iter();
|
||||
}
|
||||
|
||||
children.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_a_parent_of<P: AsRef<Path>>(parent: P, child: P) -> bool {
|
||||
let parent = parent.as_ref();
|
||||
let child = child.as_ref();
|
||||
|
||||
Reference in New Issue
Block a user