From 42a7f2fc774ac5eab6ab0bf59bdaf776e5d85739 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 3 Aug 2024 23:04:26 +0300 Subject: [PATCH] apply clippy lints --- src/desktop.rs | 2 +- src/main.rs | 17 ++++++++--------- src/release.rs | 2 +- src/system.rs | 8 +++----- src/uptime.rs | 6 +++--- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/desktop.rs b/src/desktop.rs index 273516d..1f017f6 100644 --- a/src/desktop.rs +++ b/src/desktop.rs @@ -9,5 +9,5 @@ pub fn get_desktop_info() -> Result { // instead of just "foo" let desktop_env = desktop_env.trim_start_matches("none+"); - Ok(format!("{} ({})", desktop_env, display_backend)) + Ok(format!("{desktop_env} ({display_backend})")) } diff --git a/src/main.rs b/src/main.rs index ee3f5a5..4203ad7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,15 +27,14 @@ fn main() -> Result<(), Report> { println!( " -{CYAN} ▗▄ {BLUE}▗▄ ▄▖ {} ~{RESET} -{CYAN} ▄▄🬸█▄▄▄{BLUE}🬸█▛ {CYAN}▃ {CYAN} {BLUE}System{RESET}  {} -{BLUE} ▟▛ ▜{CYAN}▃▟🬕 {CYAN} {BLUE}Kernel{RESET}  {} -{BLUE}🬋🬋🬫█ {CYAN}█🬛🬋🬋 {CYAN} {BLUE}Uptime{RESET}  {} -{BLUE} 🬷▛🮃{CYAN}▙ ▟▛ {CYAN} {BLUE}WM{RESET}  {} -{BLUE} 🮃 {CYAN}▟█🬴{BLUE}▀▀▀█🬴▀▀ {CYAN}󰍛 {BLUE}Memory{RESET}  {} -{CYAN} ▝▀ ▀▘ {BLUE}▀▘ {CYAN}󱥎 {BLUE}Storage (/){RESET}  {} - ", - user_info, os_name, kernel_version, uptime, window_manager, memory_usage, storage +{CYAN} ▗▄ {BLUE}▗▄ ▄▖ {user_info} ~{RESET} +{CYAN} ▄▄🬸█▄▄▄{BLUE}🬸█▛ {CYAN}▃ {CYAN} {BLUE}System{RESET}  {os_name} +{BLUE} ▟▛ ▜{CYAN}▃▟🬕 {CYAN} {BLUE}Kernel{RESET}  {kernel_version} +{BLUE}🬋🬋🬫█ {CYAN}█🬛🬋🬋 {CYAN} {BLUE}Uptime{RESET}  {uptime} +{BLUE} 🬷▛🮃{CYAN}▙ ▟▛ {CYAN} {BLUE}WM{RESET}  {window_manager} +{BLUE} 🮃 {CYAN}▟█🬴{BLUE}▀▀▀█🬴▀▀ {CYAN}󰍛 {BLUE}Memory{RESET}  {memory_usage} +{CYAN} ▝▀ ▀▘ {BLUE}▀▘ {CYAN}󱥎 {BLUE}Storage (/){RESET}  {storage} + " ); Ok(()) diff --git a/src/release.rs b/src/release.rs index d501352..47ef735 100644 --- a/src/release.rs +++ b/src/release.rs @@ -34,7 +34,7 @@ pub fn get_system_info() -> Result { let architecture = get_architecture()?; - let result = format!("{} {} ({})", system, kernel_release, architecture); + let result = format!("{system} {kernel_release} ({architecture})"); Ok(result) } diff --git a/src/system.rs b/src/system.rs index 7844643..7ceee82 100644 --- a/src/system.rs +++ b/src/system.rs @@ -13,7 +13,7 @@ pub fn get_username_and_hostname() -> Result { let output = Command::new("hostname").output()?; let hostname = String::from_utf8_lossy(&output.stdout).trim().to_string(); - Ok(format!("{YELLOW}{}{RED}@{GREEN}{}", username, hostname)) + Ok(format!("{YELLOW}{username}{RED}@{GREEN}{hostname}")) } pub fn get_root_disk_usage() -> Result> { @@ -30,8 +30,7 @@ pub fn get_root_disk_usage() -> Result> { let usage_percentage = (used_size as f64 / total_size as f64) * 100.0; Ok(format!( - "{:.2} GiB / {:.2} GiB ({CYAN}{:.0}%{RESET})", - used_size_gib, total_size_gib, usage_percentage + "{used_size_gib:.2} GiB / {total_size_gib:.2} GiB ({CYAN}{usage_percentage:.0}%{RESET})" )) } @@ -78,7 +77,6 @@ pub fn get_memory_usage() -> Result { let percentage_used = (used_memory / total_memory * 100.0).round() as u64; Ok(format!( - "{:.2} GiB / {:.2} GiB ({CYAN}{}%{RESET})", - used_memory, total_memory, percentage_used + "{used_memory:.2} GiB / {total_memory:.2} GiB ({CYAN}{percentage_used}%{RESET})" )) } diff --git a/src/uptime.rs b/src/uptime.rs index 407ff64..d9b0520 100644 --- a/src/uptime.rs +++ b/src/uptime.rs @@ -27,15 +27,15 @@ pub fn get_system_uptime() -> Result { let mut parts = Vec::new(); if days > 0 { - parts.push(format!("{} days", days)); + parts.push(format!("{days} days")); } if hours > 0 || days > 0 { - parts.push(format!("{} hours", hours)); + parts.push(format!("{hours} hours")); } if minutes > 0 || hours > 0 || days > 0 { - parts.push(format!("{} minutes", minutes)); + parts.push(format!("{minutes} minutes")); } Ok(parts.join(", "))