Skip to content

Commit

Permalink
Merge pull request #8 from tsathishkumar/master
Browse files Browse the repository at this point in the history
Happy clippy
  • Loading branch information
Sebastian Thiel committed Jun 7, 2019
2 parents 95685f1 + 3fc9beb commit 047e424
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
}
}
Expand Down Expand Up @@ -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(' ');
Expand Down Expand Up @@ -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 }
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/interactive/app/bytevis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/interactive/app/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {}
}
}

Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/interactive/widgets/mark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tui-react/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down

0 comments on commit 047e424

Please sign in to comment.