diff options
Diffstat (limited to 'src')
-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 |
5 files changed, 12 insertions, 15 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) |