diff options
author | qkzk <qu3nt1n@gmail.com> | 2023-11-07 09:42:15 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2023-11-07 09:42:15 +0100 |
commit | e1628f5e2e6b540c8680a76931d34ea0aff189ff (patch) | |
tree | e06c34631a56e463fbf0358af81d16d5daf220b5 /src/tree.rs | |
parent | 7047cce927791ca386a87edf289d2fd1a5cbd91b (diff) |
use Go trait instead of selections
Diffstat (limited to 'src/tree.rs')
-rw-r--r-- | src/tree.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tree.rs b/src/tree.rs index 68229e7..aee8312 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -86,6 +86,8 @@ impl Node { self.children = children } } + +/// Describe a movement in a navigable structure pub trait Go { fn go(&mut self, direction: To); } @@ -345,7 +347,7 @@ impl Tree { } } - pub fn select_root(&mut self) { + fn select_root(&mut self) { let Some(selected_node) = self.nodes.get_mut(&self.selected) else { unreachable!("selected path should be in node") }; @@ -358,7 +360,7 @@ impl Tree { self.reset_required_height() } - pub fn select_last(&mut self) { + fn select_last(&mut self) { let Some(selected_node) = self.nodes.get_mut(&self.selected) else { unreachable!("selected path should be in node") }; @@ -371,7 +373,7 @@ impl Tree { self.set_required_height_to_max() } - pub fn select_parent(&mut self) { + fn select_parent(&mut self) { if let Some(parent_path) = self.selected.parent() { let Some(parent_node) = self.nodes.get_mut(parent_path) else { return; @@ -386,7 +388,7 @@ impl Tree { } } - pub fn select_path(&mut self, clicked_path: &Path) { + fn select_path(&mut self, clicked_path: &Path) { let Some(new_node) = self.nodes.get_mut(clicked_path) else { return; }; |