From 0659a5ae6f85a9687b04c5465eae9dcc5ec5b7c4 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Sun, 24 Oct 2021 03:13:45 +0200 Subject: [PATCH] refactor(lint): adapt to future lints --- src/lib.rs | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 05b4d1b..96c2a60 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,23 +14,13 @@ pub mod identifier; pub use self::flatten::flatten; -#[derive(Debug, Clone)] +#[derive(Debug, Default, Clone)] pub struct TreeState { offset: usize, selected: TreeIdentifierVec, opened: HashSet, } -impl Default for TreeState { - fn default() -> Self { - Self { - offset: 0, - selected: Vec::new(), - opened: HashSet::new(), - } - } -} - impl TreeState { pub fn selected(&self) -> Vec { self.selected.clone() @@ -74,7 +64,7 @@ impl TreeState { self.opened.iter().cloned().collect() } - pub fn get_offset(&self) -> usize { + pub const fn get_offset(&self) -> usize { self.offset } } @@ -122,7 +112,7 @@ impl<'a> TreeItem<'a> { self.text.height() } - pub fn style(mut self, style: Style) -> Self { + pub const fn style(mut self, style: Style) -> Self { self.style = style; self } @@ -165,22 +155,22 @@ impl<'a> Tree<'a> { self } - pub fn style(mut self, style: Style) -> Self { + pub const fn style(mut self, style: Style) -> Self { self.style = style; self } - pub fn highlight_symbol(mut self, highlight_symbol: &'a str) -> Self { + pub const fn highlight_symbol(mut self, highlight_symbol: &'a str) -> Self { self.highlight_symbol = Some(highlight_symbol); self } - pub fn highlight_style(mut self, style: Style) -> Self { + pub const fn highlight_style(mut self, style: Style) -> Self { self.highlight_style = style; self } - pub fn start_corner(mut self, corner: Corner) -> Self { + pub const fn start_corner(mut self, corner: Corner) -> Self { self.start_corner = corner; self }