From e8f6d4853a3c320f1de53451c39ef7871d18623d Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Thu, 24 Aug 2023 20:26:46 -0400 Subject: other: appease clippy after Rust 1.72.0 (#1281) * deps: use clap 4.4.0 to remove is-terminal * fmt * appease clippy * fmt again * Revert "deps: use clap 4.4.0 to remove is-terminal" This reverts commit 78aa6ec8481d38357adc09e262aa5df87796b6c7. --- src/app/data_harvester/disks.rs | 2 +- src/app/data_harvester/temperature/linux.rs | 2 +- src/app/query.rs | 1 - src/app/states.rs | 4 ++-- src/constants.rs | 28 ++++++++++++++-------------- src/data_conversion.rs | 2 +- src/options.rs | 2 +- src/widgets/process_table.rs | 20 ++++---------------- tests/layout_management_tests.rs | 9 +++++---- 9 files changed, 29 insertions(+), 41 deletions(-) diff --git a/src/app/data_harvester/disks.rs b/src/app/data_harvester/disks.rs index e27f7f75..c4a66eff 100644 --- a/src/app/data_harvester/disks.rs +++ b/src/app/data_harvester/disks.rs @@ -97,7 +97,7 @@ cfg_if! { /// 2. Is the entry denied through any filter? That is, does it match an entry in a /// filter where `is_list_ignored` is `true`? If so, we always deny this entry. /// 3. Anything else is allowed. -pub(self) fn keep_disk_entry( +pub fn keep_disk_entry( disk_name: &str, mount_point: &str, disk_filter: &Option, mount_filter: &Option, ) -> bool { match (disk_filter, mount_filter) { diff --git a/src/app/data_harvester/temperature/linux.rs b/src/app/data_harvester/temperature/linux.rs index 328b0761..8021bc8c 100644 --- a/src/app/data_harvester/temperature/linux.rs +++ b/src/app/data_harvester/temperature/linux.rs @@ -318,7 +318,7 @@ fn add_thermal_zone_temperatures( ) { let path = Path::new("/sys/class/thermal"); let Ok(read_dir) = path.read_dir() else { - return + return; }; let mut seen_names: HashMap = HashMap::new(); diff --git a/src/app/query.rs b/src/app/query.rs index 67131893..b99fb0ec 100644 --- a/src/app/query.rs +++ b/src/app/query.rs @@ -328,7 +328,6 @@ pub fn parse_query( }), )), }); - } else { } } _ => { diff --git a/src/app/states.rs b/src/app/states.rs index 0f01af75..f22a0221 100644 --- a/src/app/states.rs +++ b/src/app/states.rs @@ -219,7 +219,7 @@ impl AppSearchState { .next_boundary(chunk, start_position) .unwrap(); } - _ => Err(err).unwrap(), + _ => panic!("{err:?}"), }, } } @@ -239,7 +239,7 @@ impl AppSearchState { self.grapheme_cursor.prev_boundary(chunk, 0).unwrap(); } - _ => Err(err).unwrap(), + _ => panic!("{err:?}"), }, } } diff --git a/src/constants.rs b/src/constants.rs index 9a0cd04a..bf73529a 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -448,7 +448,7 @@ pub const HELP_TEXT: [&[&str]; HELP_CONTENTS_TEXT.len()] = [ ]; // Default layouts -pub const DEFAULT_LAYOUT: &str = r##" +pub const DEFAULT_LAYOUT: &str = r#" [[row]] ratio=30 [[row.child]] @@ -471,9 +471,9 @@ pub const DEFAULT_LAYOUT: &str = r##" [[row.child]] type="proc" default=true -"##; +"#; -pub const DEFAULT_BATTERY_LAYOUT: &str = r##" +pub const DEFAULT_BATTERY_LAYOUT: &str = r#" [[row]] ratio=30 [[row.child]] @@ -500,13 +500,13 @@ pub const DEFAULT_BATTERY_LAYOUT: &str = r##" [[row.child]] type="proc" default=true -"##; +"#; // Config and flags pub const DEFAULT_CONFIG_FILE_PATH: &str = "bottom/bottom.toml"; // TODO: Eventually deprecate this, or grab from a file. -pub const CONFIG_TEXT: &str = r##"# This is a default config file for bottom. All of the settings are commented +pub const CONFIG_TEXT: &str = r#"# This is a default config file for bottom. All of the settings are commented # out by default; if you wish to change them uncomment and modify as you see # fit. @@ -695,7 +695,7 @@ pub const CONFIG_TEXT: &str = r##"# This is a default config file for bottom. A #regex = true #case_sensitive = false #whole_word = false -"##; +"#; pub const CONFIG_TOP_HEAD: &str = r##"# This is bottom's config file. # Values in this config file will change when changed in the interface. @@ -706,19 +706,19 @@ pub const CONFIG_TOP_HEAD: &str = r##"# This is bottom's config file. "##; -pub const CONFIG_DISPLAY_OPTIONS_HEAD: &str = r##" +pub const CONFIG_DISPLAY_OPTIONS_HEAD: &str = r#" # These options represent settings that affect how bottom functions. # If a setting here corresponds to command-line flag, then the flag will temporarily override # the setting. -"##; +"#; -pub const CONFIG_COLOUR_HEAD: &str = r##" +pub const CONFIG_COLOUR_HEAD: &str = r#" # These options represent colour values for various parts of bottom. Note that colour support # will ultimately depend on the terminal - for example, the Terminal for macOS does NOT like # custom colours and it may glitch out. -"##; +"#; -pub const CONFIG_LAYOUT_HEAD: &str = r##" +pub const CONFIG_LAYOUT_HEAD: &str = r#" # These options represent how bottom will lay out its widgets. Layouts follow a pattern like this: # [[row]] represents a row in the application. # [[row.child]] represents either a widget or a column. @@ -726,11 +726,11 @@ pub const CONFIG_LAYOUT_HEAD: &str = r##" # # All widgets must have the valid type value set to one of ["cpu", "mem", "proc", "net", "temp", "disk", "empty"]. # All layout components have a ratio value - if this is not set, then it defaults to 1. -"##; +"#; -pub const CONFIG_FILTER_HEAD: &str = r##" +pub const CONFIG_FILTER_HEAD: &str = r#" # These options represent disabled entries for the temperature and disk widgets. -"##; +"#; #[cfg(test)] mod test { diff --git a/src/data_conversion.rs b/src/data_conversion.rs index 0bbe9eb3..8064c81a 100644 --- a/src/data_conversion.rs +++ b/src/data_conversion.rs @@ -631,7 +631,7 @@ pub fn convert_gpu_data( let results = current_data .gpu_harvest .iter() - .zip(point_vec.into_iter()) + .zip(point_vec) .map(|(gpu, points)| { let short_name = { let last_words = gpu.0.split_whitespace().rev().take(2).collect::>(); diff --git a/src/options.rs b/src/options.rs index 26b21d7f..f2c56d9d 100644 --- a/src/options.rs +++ b/src/options.rs @@ -252,7 +252,7 @@ pub fn build_app( if columns.is_empty() { None } else { - Some(IndexSet::from_iter(columns.into_iter())) + Some(IndexSet::from_iter(columns)) } } None => None, diff --git a/src/widgets/process_table.rs b/src/widgets/process_table.rs index daa6710e..41db8706 100644 --- a/src/widgets/process_table.rs +++ b/src/widgets/process_table.rs @@ -1063,10 +1063,7 @@ mod test { data.sort_by_key(|p| p.pid); sort_skip_pid_asc(&ProcColumn::CpuPercent, &mut data, SortOrder::Descending); assert_eq!( - vec![&c, &b, &a, &d] - .iter() - .map(|d| (d.pid)) - .collect::>(), + [&c, &b, &a, &d].iter().map(|d| (d.pid)).collect::>(), data.iter().map(|d| (d.pid)).collect::>(), ); @@ -1074,20 +1071,14 @@ mod test { data.sort_by_key(|p| p.pid); sort_skip_pid_asc(&ProcColumn::CpuPercent, &mut data, SortOrder::Ascending); assert_eq!( - vec![&a, &d, &b, &c] - .iter() - .map(|d| (d.pid)) - .collect::>(), + [&a, &d, &b, &c].iter().map(|d| (d.pid)).collect::>(), data.iter().map(|d| (d.pid)).collect::>(), ); data.sort_by_key(|p| p.pid); sort_skip_pid_asc(&ProcColumn::MemoryPercent, &mut data, SortOrder::Descending); assert_eq!( - vec![&b, &a, &c, &d] - .iter() - .map(|d| (d.pid)) - .collect::>(), + [&b, &a, &c, &d].iter().map(|d| (d.pid)).collect::>(), data.iter().map(|d| (d.pid)).collect::>(), ); @@ -1095,10 +1086,7 @@ mod test { data.sort_by_key(|p| p.pid); sort_skip_pid_asc(&ProcColumn::MemoryPercent, &mut data, SortOrder::Ascending); assert_eq!( - vec![&c, &d, &a, &b] - .iter() - .map(|d| (d.pid)) - .collect::>(), + [&c, &d, &a, &b].iter().map(|d| (d.pid)).collect::>(), data.iter().map(|d| (d.pid)).collect::>(), ); } diff --git a/tests/layout_management_tests.rs b/tests/layout_management_tests.rs index 7dd6114c..811c7315 100644 --- a/tests/layout_management_tests.rs +++ b/tests/layout_management_tests.rs @@ -10,7 +10,7 @@ use toml_edit::de::from_str; // TODO: Could move these into the library files rather than external tbh. -const PROC_LAYOUT: &str = r##" +const PROC_LAYOUT: &str = r#" [[row]] [[row.child]] type="proc" @@ -24,7 +24,7 @@ const PROC_LAYOUT: &str = r##" type="proc" [[row.child]] type="proc" -"##; +"#; fn test_create_layout( rows: &[Row], default_widget_id: u64, default_widget_type: Option, @@ -221,7 +221,7 @@ fn test_left_legend() { #[test] /// Tests explicit default widget. fn test_default_widget_in_layout() { - let proc_layout = r##" + let proc_layout = r#" [[row]] [[row.child]] type="proc" @@ -236,7 +236,8 @@ fn test_default_widget_in_layout() { default=true [[row.child]] type="proc" - "##; + "#; + let rows = from_str::(proc_layout).unwrap().row.unwrap(); let mut iter_id = 0; // A lazy way of forcing unique IDs *shrugs* let mut total_height_ratio = 0; -- cgit v1.2.3