Skip to content

Commit

Permalink
refactor: run clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang committed May 15, 2022
1 parent 6172226 commit 385f205
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/app/widgets/process_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ impl ProcWidgetColumn {
})
}
} else {
#[allow(clippy::collapsible-else-if)]
if sort_descending {
data.sort_by_cached_key(|p| {
Reverse(name_pid_map.get(&p.name).map(|v| v.len()).unwrap_or(0))
Expand Down Expand Up @@ -501,7 +502,7 @@ impl ProcWidget {
{
let shown_children = children_pids
.iter()
.filter(|pid| visited_pids.get(*pid).map(|b| *b).unwrap_or(false))
.filter(|pid| visited_pids.get(*pid).copied().unwrap_or(false))
.collect_vec();
let is_shown = is_process_matching || !shown_children.is_empty();
visited_pids.insert(process.pid, is_shown);
Expand Down Expand Up @@ -545,7 +546,7 @@ impl ProcWidget {
.filter_map(|child| process_harvest.get(child))
.collect_vec();

self.try_sort(&mut stack, &data_collection);
self.try_sort(&mut stack, data_collection);

let mut length_stack = vec![stack.len()];

Expand Down Expand Up @@ -687,8 +688,8 @@ impl ProcWidget {
filtered_iter.collect::<Vec<_>>()
};

self.try_sort(&mut filtered_data, &data_collection);
self.harvest_to_table_data(&filtered_data, &data_collection)
self.try_sort(&mut filtered_data, data_collection);
self.harvest_to_table_data(&filtered_data, data_collection)
}

fn try_sort(&self, filtered_data: &mut [&ProcessHarvest], data_collection: &DataCollection) {
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/components/text_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ fn build_header<'a, H: TableComponentHeader>(
}

/// Truncates text if it is too long, and adds an ellipsis at the end if needed.
fn truncate_text<'a>(content: &'a CellContent, width: usize, row_style: Option<Style>) -> Text<'a> {
fn truncate_text(content: &CellContent, width: usize, row_style: Option<Style>) -> Text<'_> {
let (main_text, alt_text) = match content {
CellContent::Simple(s) => (s, None),
CellContent::HasAlt {
Expand Down
7 changes: 2 additions & 5 deletions src/canvas/widgets/process_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,8 @@ impl Painter {
// TODO: [Refactor] This is an ugly hack to add the disabled style...
// this could be solved by storing style locally to the widget.
for row in &mut proc_widget_state.table_data.data {
match row {
TableRow::Styled(_, style) => {
*style = style.patch(self.colours.disabled_text_style);
}
_ => {}
if let TableRow::Styled(_, style) = row {
*style = style.patch(self.colours.disabled_text_style);
}
}

Expand Down

0 comments on commit 385f205

Please sign in to comment.