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.
This commit is contained in:
Clement Tsang 2023-08-24 20:26:46 -04:00 committed by GitHub
parent 713b1874b7
commit e8f6d4853a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 41 deletions

View File

@ -97,7 +97,7 @@ cfg_if! {
/// 2. Is the entry denied through any filter? That is, does it match an entry in a /// 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. /// filter where `is_list_ignored` is `true`? If so, we always deny this entry.
/// 3. Anything else is allowed. /// 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<Filter>, mount_filter: &Option<Filter>, disk_name: &str, mount_point: &str, disk_filter: &Option<Filter>, mount_filter: &Option<Filter>,
) -> bool { ) -> bool {
match (disk_filter, mount_filter) { match (disk_filter, mount_filter) {

View File

@ -318,7 +318,7 @@ fn add_thermal_zone_temperatures(
) { ) {
let path = Path::new("/sys/class/thermal"); let path = Path::new("/sys/class/thermal");
let Ok(read_dir) = path.read_dir() else { let Ok(read_dir) = path.read_dir() else {
return return;
}; };
let mut seen_names: HashMap<String, u32> = HashMap::new(); let mut seen_names: HashMap<String, u32> = HashMap::new();

View File

@ -328,7 +328,6 @@ pub fn parse_query(
}), }),
)), )),
}); });
} else {
} }
} }
_ => { _ => {

View File

@ -219,7 +219,7 @@ impl AppSearchState {
.next_boundary(chunk, start_position) .next_boundary(chunk, start_position)
.unwrap(); .unwrap();
} }
_ => Err(err).unwrap(), _ => panic!("{err:?}"),
}, },
} }
} }
@ -239,7 +239,7 @@ impl AppSearchState {
self.grapheme_cursor.prev_boundary(chunk, 0).unwrap(); self.grapheme_cursor.prev_boundary(chunk, 0).unwrap();
} }
_ => Err(err).unwrap(), _ => panic!("{err:?}"),
}, },
} }
} }

View File

@ -448,7 +448,7 @@ pub const HELP_TEXT: [&[&str]; HELP_CONTENTS_TEXT.len()] = [
]; ];
// Default layouts // Default layouts
pub const DEFAULT_LAYOUT: &str = r##" pub const DEFAULT_LAYOUT: &str = r#"
[[row]] [[row]]
ratio=30 ratio=30
[[row.child]] [[row.child]]
@ -471,9 +471,9 @@ pub const DEFAULT_LAYOUT: &str = r##"
[[row.child]] [[row.child]]
type="proc" type="proc"
default=true default=true
"##; "#;
pub const DEFAULT_BATTERY_LAYOUT: &str = r##" pub const DEFAULT_BATTERY_LAYOUT: &str = r#"
[[row]] [[row]]
ratio=30 ratio=30
[[row.child]] [[row.child]]
@ -500,13 +500,13 @@ pub const DEFAULT_BATTERY_LAYOUT: &str = r##"
[[row.child]] [[row.child]]
type="proc" type="proc"
default=true default=true
"##; "#;
// Config and flags // Config and flags
pub const DEFAULT_CONFIG_FILE_PATH: &str = "bottom/bottom.toml"; pub const DEFAULT_CONFIG_FILE_PATH: &str = "bottom/bottom.toml";
// TODO: Eventually deprecate this, or grab from a file. // 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 # out by default; if you wish to change them uncomment and modify as you see
# fit. # fit.
@ -695,7 +695,7 @@ pub const CONFIG_TEXT: &str = r##"# This is a default config file for bottom. A
#regex = true #regex = true
#case_sensitive = false #case_sensitive = false
#whole_word = false #whole_word = false
"##; "#;
pub const CONFIG_TOP_HEAD: &str = r##"# This is bottom's config file. 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. # 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. # These options represent settings that affect how bottom functions.
# If a setting here corresponds to command-line flag, then the flag will temporarily override # If a setting here corresponds to command-line flag, then the flag will temporarily override
# the setting. # 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 # 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 # will ultimately depend on the terminal - for example, the Terminal for macOS does NOT like
# custom colours and it may glitch out. # 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: # These options represent how bottom will lay out its widgets. Layouts follow a pattern like this:
# [[row]] represents a row in the application. # [[row]] represents a row in the application.
# [[row.child]] represents either a widget or a column. # [[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 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. # 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. # These options represent disabled entries for the temperature and disk widgets.
"##; "#;
#[cfg(test)] #[cfg(test)]
mod test { mod test {

View File

@ -631,7 +631,7 @@ pub fn convert_gpu_data(
let results = current_data let results = current_data
.gpu_harvest .gpu_harvest
.iter() .iter()
.zip(point_vec.into_iter()) .zip(point_vec)
.map(|(gpu, points)| { .map(|(gpu, points)| {
let short_name = { let short_name = {
let last_words = gpu.0.split_whitespace().rev().take(2).collect::<Vec<_>>(); let last_words = gpu.0.split_whitespace().rev().take(2).collect::<Vec<_>>();

View File

@ -252,7 +252,7 @@ pub fn build_app(
if columns.is_empty() { if columns.is_empty() {
None None
} else { } else {
Some(IndexSet::from_iter(columns.into_iter())) Some(IndexSet::from_iter(columns))
} }
} }
None => None, None => None,

View File

@ -1063,10 +1063,7 @@ mod test {
data.sort_by_key(|p| p.pid); data.sort_by_key(|p| p.pid);
sort_skip_pid_asc(&ProcColumn::CpuPercent, &mut data, SortOrder::Descending); sort_skip_pid_asc(&ProcColumn::CpuPercent, &mut data, SortOrder::Descending);
assert_eq!( assert_eq!(
vec![&c, &b, &a, &d] [&c, &b, &a, &d].iter().map(|d| (d.pid)).collect::<Vec<_>>(),
.iter()
.map(|d| (d.pid))
.collect::<Vec<_>>(),
data.iter().map(|d| (d.pid)).collect::<Vec<_>>(), data.iter().map(|d| (d.pid)).collect::<Vec<_>>(),
); );
@ -1074,20 +1071,14 @@ mod test {
data.sort_by_key(|p| p.pid); data.sort_by_key(|p| p.pid);
sort_skip_pid_asc(&ProcColumn::CpuPercent, &mut data, SortOrder::Ascending); sort_skip_pid_asc(&ProcColumn::CpuPercent, &mut data, SortOrder::Ascending);
assert_eq!( assert_eq!(
vec![&a, &d, &b, &c] [&a, &d, &b, &c].iter().map(|d| (d.pid)).collect::<Vec<_>>(),
.iter()
.map(|d| (d.pid))
.collect::<Vec<_>>(),
data.iter().map(|d| (d.pid)).collect::<Vec<_>>(), data.iter().map(|d| (d.pid)).collect::<Vec<_>>(),
); );
data.sort_by_key(|p| p.pid); data.sort_by_key(|p| p.pid);
sort_skip_pid_asc(&ProcColumn::MemoryPercent, &mut data, SortOrder::Descending); sort_skip_pid_asc(&ProcColumn::MemoryPercent, &mut data, SortOrder::Descending);
assert_eq!( assert_eq!(
vec![&b, &a, &c, &d] [&b, &a, &c, &d].iter().map(|d| (d.pid)).collect::<Vec<_>>(),
.iter()
.map(|d| (d.pid))
.collect::<Vec<_>>(),
data.iter().map(|d| (d.pid)).collect::<Vec<_>>(), data.iter().map(|d| (d.pid)).collect::<Vec<_>>(),
); );
@ -1095,10 +1086,7 @@ mod test {
data.sort_by_key(|p| p.pid); data.sort_by_key(|p| p.pid);
sort_skip_pid_asc(&ProcColumn::MemoryPercent, &mut data, SortOrder::Ascending); sort_skip_pid_asc(&ProcColumn::MemoryPercent, &mut data, SortOrder::Ascending);
assert_eq!( assert_eq!(
vec![&c, &d, &a, &b] [&c, &d, &a, &b].iter().map(|d| (d.pid)).collect::<Vec<_>>(),
.iter()
.map(|d| (d.pid))
.collect::<Vec<_>>(),
data.iter().map(|d| (d.pid)).collect::<Vec<_>>(), data.iter().map(|d| (d.pid)).collect::<Vec<_>>(),
); );
} }

View File

@ -10,7 +10,7 @@ use toml_edit::de::from_str;
// TODO: Could move these into the library files rather than external tbh. // TODO: Could move these into the library files rather than external tbh.
const PROC_LAYOUT: &str = r##" const PROC_LAYOUT: &str = r#"
[[row]] [[row]]
[[row.child]] [[row.child]]
type="proc" type="proc"
@ -24,7 +24,7 @@ const PROC_LAYOUT: &str = r##"
type="proc" type="proc"
[[row.child]] [[row.child]]
type="proc" type="proc"
"##; "#;
fn test_create_layout( fn test_create_layout(
rows: &[Row], default_widget_id: u64, default_widget_type: Option<BottomWidgetType>, rows: &[Row], default_widget_id: u64, default_widget_type: Option<BottomWidgetType>,
@ -221,7 +221,7 @@ fn test_left_legend() {
#[test] #[test]
/// Tests explicit default widget. /// Tests explicit default widget.
fn test_default_widget_in_layout() { fn test_default_widget_in_layout() {
let proc_layout = r##" let proc_layout = r#"
[[row]] [[row]]
[[row.child]] [[row.child]]
type="proc" type="proc"
@ -236,7 +236,8 @@ fn test_default_widget_in_layout() {
default=true default=true
[[row.child]] [[row.child]]
type="proc" type="proc"
"##; "#;
let rows = from_str::<Config>(proc_layout).unwrap().row.unwrap(); let rows = from_str::<Config>(proc_layout).unwrap().row.unwrap();
let mut iter_id = 0; // A lazy way of forcing unique IDs *shrugs* let mut iter_id = 0; // A lazy way of forcing unique IDs *shrugs*
let mut total_height_ratio = 0; let mut total_height_ratio = 0;