other: delete redundant code, run clippy and fmt

This commit is contained in:
ClementTsang 2022-05-15 04:39:47 -04:00
parent ed17264832
commit 05e9cd4d4d
6 changed files with 11 additions and 27 deletions

View file

@ -411,19 +411,3 @@ pub struct ParagraphScrollState {
pub current_scroll_index: u16,
pub max_scroll_index: u16,
}
#[derive(Default)]
pub struct ConfigState {
pub current_category_index: usize,
pub category_list: Vec<ConfigCategory>,
}
#[derive(Default)]
pub struct ConfigCategory {
pub category_name: &'static str,
pub options_list: Vec<ConfigOption>,
}
pub struct ConfigOption {
pub set_function: Box<dyn Fn() -> anyhow::Result<()>>,
}

View file

@ -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))
@ -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);
@ -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()];
@ -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) {

View file

@ -69,6 +69,8 @@ pub struct Painter {
width: u16,
styled_help_text: Vec<Spans<'static>>,
is_mac_os: bool, // FIXME: This feels out of place...
// FIXME: Redo this entire thing.
row_constraints: Vec<Constraint>,
col_constraints: Vec<Vec<Constraint>>,
col_row_constraints: Vec<Vec<Vec<Constraint>>>,

View file

@ -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 {

View file

@ -9,7 +9,7 @@ use tui::{
};
use crate::{
app::{App, KillSignal, widgets::ProcWidgetMode},
app::{widgets::ProcWidgetMode, App, KillSignal},
canvas::Painter,
};

View file

@ -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);
}
}