Skip to content

Commit

Permalink
other: appease clippy after Rust 1.72.0 (#1281)
Browse files Browse the repository at this point in the history
* 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 78aa6ec.
  • Loading branch information
ClementTsang committed Aug 25, 2023
1 parent 713b187 commit e8f6d48
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/app/data_harvester/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Filter>, mount_filter: &Option<Filter>,
) -> bool {
match (disk_filter, mount_filter) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/data_harvester/temperature/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, u32> = HashMap::new();
Expand Down
1 change: 0 additions & 1 deletion src/app/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ pub fn parse_query(
}),
)),
});
} else {
}
}
_ => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl AppSearchState {
.next_boundary(chunk, start_position)
.unwrap();
}
_ => Err(err).unwrap(),
_ => panic!("{err:?}"),
},
}
}
Expand All @@ -239,7 +239,7 @@ impl AppSearchState {

self.grapheme_cursor.prev_boundary(chunk, 0).unwrap();
}
_ => Err(err).unwrap(),
_ => panic!("{err:?}"),
},
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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]]
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -706,31 +706,31 @@ 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.
# [[row.child.child]] represents a widget.
#
# 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/data_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();
Expand Down
2 changes: 1 addition & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 4 additions & 16 deletions src/widgets/process_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,42 +1063,30 @@ 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::<Vec<_>>(),
[&c, &b, &a, &d].iter().map(|d| (d.pid)).collect::<Vec<_>>(),
data.iter().map(|d| (d.pid)).collect::<Vec<_>>(),
);

// Note that the PID ordering for ties is still ascending.
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::<Vec<_>>(),
[&a, &d, &b, &c].iter().map(|d| (d.pid)).collect::<Vec<_>>(),
data.iter().map(|d| (d.pid)).collect::<Vec<_>>(),
);

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::<Vec<_>>(),
[&b, &a, &c, &d].iter().map(|d| (d.pid)).collect::<Vec<_>>(),
data.iter().map(|d| (d.pid)).collect::<Vec<_>>(),
);

// Note that the PID ordering for ties is still ascending.
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::<Vec<_>>(),
[&c, &d, &a, &b].iter().map(|d| (d.pid)).collect::<Vec<_>>(),
data.iter().map(|d| (d.pid)).collect::<Vec<_>>(),
);
}
Expand Down
9 changes: 5 additions & 4 deletions tests/layout_management_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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<BottomWidgetType>,
Expand Down Expand Up @@ -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"
Expand All @@ -236,7 +236,8 @@ fn test_default_widget_in_layout() {
default=true
[[row.child]]
type="proc"
"##;
"#;

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 total_height_ratio = 0;
Expand Down

0 comments on commit e8f6d48

Please sign in to comment.