diff options
author | Yuri Astrakhan <yuriastrakhan@gmail.com> | 2023-11-15 03:47:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 03:47:22 -0500 |
commit | 5eb4fbde5d7e41cd39dcb7c95e1bbf542e706cb0 (patch) | |
tree | 13b0ba47b78190b294b54d05eb4821306a6687f3 /src/app | |
parent | a6200640b9a074feb116b7808543c8cb73c8dd30 (diff) |
chore: fix certain uninlined string format uses (#1310)
* Fixed uninlined args
First ran this, and fixed a few more similar issues by hand
```
cargo clippy --workspace --fix --benches --tests --bins -- -A clippy::all -W clippy::uninlined_format_args
```
Note that in a few cases, format args were passed by ref - which is actually a tiny perf hit - compiler would not be able to optimize them.
* revert change here
since it contains a non-inlineable variable I'm not a fan of using it partially here
* revert
given the other formats above/below I would prefer keeping it like this
---------
Co-authored-by: Clement Tsang <34804052+ClementTsang@users.noreply.github.com>
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/data_harvester/processes/linux.rs | 2 | ||||
-rw-r--r-- | src/app/data_harvester/temperature/linux.rs | 2 | ||||
-rw-r--r-- | src/app/layout_manager.rs | 6 | ||||
-rw-r--r-- | src/app/process_killer.rs | 8 | ||||
-rw-r--r-- | src/app/query.rs | 10 |
5 files changed, 11 insertions, 17 deletions
diff --git a/src/app/data_harvester/processes/linux.rs b/src/app/data_harvester/processes/linux.rs index 89bf9db4..8f50823b 100644 --- a/src/app/data_harvester/processes/linux.rs +++ b/src/app/data_harvester/processes/linux.rs @@ -144,7 +144,7 @@ fn read_proc( let truncated_name = stat.comm.as_str(); if let Ok(cmdline) = cmdline { if cmdline.is_empty() { - (format!("[{}]", truncated_name), truncated_name.to_string()) + (format!("[{truncated_name}]"), truncated_name.to_string()) } else { ( cmdline.join(" "), diff --git a/src/app/data_harvester/temperature/linux.rs b/src/app/data_harvester/temperature/linux.rs index 8021bc8c..72ca9eef 100644 --- a/src/app/data_harvester/temperature/linux.rs +++ b/src/app/data_harvester/temperature/linux.rs @@ -123,7 +123,7 @@ fn counted_name(seen_names: &mut HashMap<String, u32>, name: String) -> String { if let Some(count) = seen_names.get_mut(&name) { *count += 1; - format!("{name} ({})", *count) + format!("{name} ({count})") } else { seen_names.insert(name.clone(), 0); name diff --git a/src/app/layout_manager.rs b/src/app/layout_manager.rs index 94e7f877..f5ed8eaa 100644 --- a/src/app/layout_manager.rs +++ b/src/app/layout_manager.rs @@ -1018,7 +1018,7 @@ impl std::str::FromStr for BottomWidgetType { #[cfg(feature = "battery")] { Err(BottomError::ConfigError(format!( - "\"{}\" is an invalid widget name. + "\"{s}\" is an invalid widget name. Supported widget names: +--------------------------+ @@ -1037,13 +1037,12 @@ Supported widget names: | batt, battery | +--------------------------+ ", - s ))) } #[cfg(not(feature = "battery"))] { Err(BottomError::ConfigError(format!( - "\"{}\" is an invalid widget name. + "\"{s}\" is an invalid widget name. Supported widget names: +--------------------------+ @@ -1060,7 +1059,6 @@ Supported widget names: | disk | +--------------------------+ ", - s ))) } } diff --git a/src/app/process_killer.rs b/src/app/process_killer.rs index 106419ee..c68b81ab 100644 --- a/src/app/process_killer.rs +++ b/src/app/process_killer.rs @@ -75,14 +75,10 @@ pub fn kill_process_given_pid(pid: Pid, signal: usize) -> crate::utils::error::R return if let Some(err_code) = err_code { Err(BottomError::GenericError(format!( - "Error code {} - {}", - err_code, err, + "Error code {err_code} - {err}" ))) } else { - Err(BottomError::GenericError(format!( - "Error code ??? - {}", - err, - ))) + Err(BottomError::GenericError(format!("Error code ??? - {err}"))) }; } diff --git a/src/app/query.rs b/src/app/query.rs index 713e7d62..85858ddc 100644 --- a/src/app/query.rs +++ b/src/app/query.rs @@ -54,7 +54,7 @@ pub fn parse_query( let mut rhs: Option<Box<And>> = None; while let Some(queue_top) = query.front() { - // debug!("OR QT: {:?}", queue_top); + // debug!("OR QT: {queue_top:?}"); if OR_LIST.contains(&queue_top.to_lowercase().as_str()) { query.pop_front(); rhs = Some(Box::new(process_and(query)?)); @@ -90,7 +90,7 @@ pub fn parse_query( let mut rhs: Option<Box<Prefix>> = None; while let Some(queue_top) = query.front() { - // debug!("AND QT: {:?}", queue_top); + // debug!("AND QT: {queue_top:?}"); if AND_LIST.contains(&queue_top.to_lowercase().as_str()) { query.pop_front(); @@ -810,11 +810,11 @@ impl Prefix { impl Debug for Prefix { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if let Some(or) = &self.or { - f.write_fmt(format_args!("{:?}", or)) + f.write_fmt(format_args!("{or:?}")) } else if let Some(regex_prefix) = &self.regex_prefix { - f.write_fmt(format_args!("{:?}", regex_prefix)) + f.write_fmt(format_args!("{regex_prefix:?}")) } else if let Some(compare_prefix) = &self.compare_prefix { - f.write_fmt(format_args!("{:?}", compare_prefix)) + f.write_fmt(format_args!("{compare_prefix:?}")) } else { f.write_fmt(format_args!("")) } |