diff options
author | Sathish <tsatiz@gmail.com> | 2019-06-07 10:44:09 +0530 |
---|---|---|
committer | Sathish <tsatiz@gmail.com> | 2019-06-07 12:13:13 +0530 |
commit | 3fc9beb205a2ad5f1da00472a6bc1a94cc64e769 (patch) | |
tree | 401160656ab6d6dea33a4d5894f53d34523eca48 | |
parent | 95685f1387b74e2bbd7c1e67d383cd5861aa3451 (diff) |
Happy clippy
-rw-r--r-- | src/common.rs | 12 | ||||
-rw-r--r-- | src/interactive/app/bytevis.rs | 4 | ||||
-rw-r--r-- | src/interactive/app/handlers.rs | 7 | ||||
-rw-r--r-- | src/interactive/widgets/mark.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 2 | ||||
-rw-r--r-- | tui-react/src/terminal.rs | 2 |
6 files changed, 13 insertions, 16 deletions
diff --git a/src/common.rs b/src/common.rs index f9fda92..1440cc4 100644 --- a/src/common.rs +++ b/src/common.rs @@ -51,7 +51,7 @@ pub enum ByteFormat { } impl ByteFormat { - pub fn width(&self) -> usize { + pub fn width(self) -> usize { use ByteFormat::*; match self { Metric | Binary => 10, @@ -60,9 +60,9 @@ impl ByteFormat { _ => 10, } } - pub fn display(&self, bytes: u64) -> ByteFormatDisplay { + pub fn display(self, bytes: u64) -> ByteFormatDisplay { ByteFormatDisplay { - format: *self, + format: self, bytes, } } @@ -92,7 +92,7 @@ impl fmt::Display for ByteFormatDisplay { (_, Some((divisor, unit))) => Byte::from_unit(self.bytes as f64 / divisor as f64, unit) .expect("byte count > 0") .get_adjusted_unit(unit), - (binary, None) => Byte::from_bytes(self.bytes as u128).get_appropriate_unit(binary), + (binary, None) => Byte::from_bytes(u128::from(self.bytes)).get_appropriate_unit(binary), } .format(2); let mut splits = b.split(' '); @@ -135,8 +135,8 @@ pub(crate) struct DisplayColor<C> { } impl Color { - pub(crate) fn display<C>(&self, color: C) -> DisplayColor<C> { - DisplayColor { kind: *self, color } + pub(crate) fn display<C>(self, color: C) -> DisplayColor<C> { + DisplayColor { kind: self, color } } } diff --git a/src/interactive/app/bytevis.rs b/src/interactive/app/bytevis.rs index 70c7714..14c6201 100644 --- a/src/interactive/app/bytevis.rs +++ b/src/interactive/app/bytevis.rs @@ -30,9 +30,9 @@ impl ByteVisualization { Percentage => Bar, } } - pub fn display(&self, percentage: f32) -> DisplayByteVisualization { + pub fn display(self, percentage: f32) -> DisplayByteVisualization { DisplayByteVisualization { - format: *self, + format: self, percentage, } } diff --git a/src/interactive/app/handlers.rs b/src/interactive/app/handlers.rs index 20fc8ec..ceddfd0 100644 --- a/src/interactive/app/handlers.rs +++ b/src/interactive/app/handlers.rs @@ -69,11 +69,8 @@ impl TerminalApp { } pub fn open_that(&mut self) { - match self.state.selected { - Some(ref idx) => { + if let Some(ref idx) = self.state.selected { open::that(path_of(&self.traversal.tree, *idx)).ok(); - } - None => {} } } @@ -120,7 +117,7 @@ impl TerminalApp { }; self.state.selected = entries .get(next_selected_pos) - .or(entries.last()) + .or_else(|| entries.last()) .map(|b| b.index) .or(self.state.selected) } diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs index 9ce6ed0..cf45c59 100644 --- a/src/interactive/widgets/mark.rs +++ b/src/interactive/widgets/mark.rs @@ -112,7 +112,7 @@ impl MarkPane { let entry_in_view = self .selected .map(|selected| selected) - .or(Some(marked.len().saturating_sub(1))); + .or_else(|| Some(marked.len().saturating_sub(1))); let selected = self.selected; let entries = marked .values() diff --git a/src/main.rs b/src/main.rs index 09d2e85..cce66d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -80,7 +80,7 @@ fn run() -> Result<(), Error> { } fn paths_from(paths: Vec<PathBuf>) -> Result<Vec<PathBuf>, io::Error> { - if paths.len() == 0 { + if paths.is_empty() { cwd_dirlist() } else { Ok(paths) diff --git a/tui-react/src/terminal.rs b/tui-react/src/terminal.rs index 3bfe1a2..f38f8ea 100644 --- a/tui-react/src/terminal.rs +++ b/tui-react/src/terminal.rs @@ -87,7 +87,7 @@ where // Autoresize - otherwise we get glitches if shrinking or potential desync between widgets // and the terminal (if growing), which may OOB. self.autoresize()?; - Ok(self.known_size.clone()) + Ok(self.known_size) } pub fn post_render(&mut self) -> io::Result<()> { |