diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2022-05-15 04:39:47 -0400 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2022-05-15 21:02:33 -0400 |
commit | 05e9cd4d4dc756fdd923f2bb7d3ab38645df8ee3 (patch) | |
tree | 584267ac55bcefe62edb399d2e9f164e3d0b6e07 /src | |
parent | ed17264832aaca8124cfd1b691ec16a560c7b50f (diff) |
other: delete redundant code, run clippy and fmt
Diffstat (limited to 'src')
-rw-r--r-- | src/app/states.rs | 16 | ||||
-rw-r--r-- | src/app/widgets/process_widget.rs | 9 | ||||
-rw-r--r-- | src/canvas.rs | 2 | ||||
-rw-r--r-- | src/canvas/components/text_table.rs | 2 | ||||
-rw-r--r-- | src/canvas/dialogs/dd_dialog.rs | 2 | ||||
-rw-r--r-- | src/canvas/widgets/process_table.rs | 7 |
6 files changed, 11 insertions, 27 deletions
diff --git a/src/app/states.rs b/src/app/states.rs index 75b27fba..3dff4644 100644 --- a/src/app/states.rs +++ b/src/app/states.rs @@ -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<()>>, -} diff --git a/src/app/widgets/process_widget.rs b/src/app/widgets/process_widget.rs index 1189d0ce..74d4c3bf 100644 --- a/src/app/widgets/process_widget.rs +++ b/src/app/widgets/process_widget.rs @@ -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) { diff --git a/src/canvas.rs b/src/canvas.rs index 43e61b44..6736c96a 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -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>>>, diff --git a/src/canvas/components/text_table.rs b/src/canvas/components/text_table.rs index 27489ed7..20b956de 100644 --- a/src/canvas/components/text_table.rs +++ b/src/canvas/components/text_table.rs @@ -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 { diff --git a/src/canvas/dialogs/dd_dialog.rs b/src/canvas/dialogs/dd_dialog.rs index 3435e381..1ee4282b 100644 --- a/src/canvas/dialogs/dd_dialog.rs +++ b/src/canvas/dialogs/dd_dialog.rs @@ -9,7 +9,7 @@ use tui::{ }; use crate::{ - app::{App, KillSignal, widgets::ProcWidgetMode}, + app::{widgets::ProcWidgetMode, App, KillSignal}, canvas::Painter, }; diff --git a/src/canvas/widgets/process_table.rs b/src/canvas/widgets/process_table.rs index 1dc68744..a5f28f5e 100644 --- a/src/canvas/widgets/process_table.rs +++ b/src/canvas/widgets/process_table.rs @@ -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); } } |