apply clippy lints

This commit is contained in:
raf 2024-08-03 23:04:26 +03:00
parent aae5f71004
commit 42a7f2fc77
Signed by: NotAShelf
GPG key ID: AF26552424E53993
5 changed files with 16 additions and 19 deletions

View file

@ -9,5 +9,5 @@ pub fn get_desktop_info() -> Result<String, io::Error> {
// instead of just "foo" // instead of just "foo"
let desktop_env = desktop_env.trim_start_matches("none+"); let desktop_env = desktop_env.trim_start_matches("none+");
Ok(format!("{} ({})", desktop_env, display_backend)) Ok(format!("{desktop_env} ({display_backend})"))
} }

View file

@ -27,15 +27,14 @@ fn main() -> Result<(), Report> {
println!( println!(
" "
{CYAN} {BLUE} {} ~{RESET} {CYAN} {BLUE} {user_info} ~{RESET}
{CYAN} 🬸{BLUE}🬸 {CYAN} {CYAN} {BLUE}System{RESET} {} {CYAN} 🬸{BLUE}🬸 {CYAN} {CYAN} {BLUE}System{RESET} {os_name}
{BLUE} {CYAN}🬕 {CYAN} {BLUE}Kernel{RESET} {} {BLUE} {CYAN}🬕 {CYAN} {BLUE}Kernel{RESET} {kernel_version}
{BLUE}🬋🬋🬫 {CYAN}🬛🬋🬋 {CYAN} {BLUE}Uptime{RESET} {} {BLUE}🬋🬋🬫 {CYAN}🬛🬋🬋 {CYAN} {BLUE}Uptime{RESET} {uptime}
{BLUE} 🬷🮃{CYAN} {CYAN} {BLUE}WM{RESET} {} {BLUE} 🬷🮃{CYAN} {CYAN} {BLUE}WM{RESET} {window_manager}
{BLUE} 🮃 {CYAN}🬴{BLUE}🬴 {CYAN}󰍛 {BLUE}Memory{RESET} {} {BLUE} 🮃 {CYAN}🬴{BLUE}🬴 {CYAN}󰍛 {BLUE}Memory{RESET} {memory_usage}
{CYAN} {BLUE} {CYAN}󱥎 {BLUE}Storage (/){RESET} {} {CYAN} {BLUE} {CYAN}󱥎 {BLUE}Storage (/){RESET} {storage}
", "
user_info, os_name, kernel_version, uptime, window_manager, memory_usage, storage
); );
Ok(()) Ok(())

View file

@ -34,7 +34,7 @@ pub fn get_system_info() -> Result<String, io::Error> {
let architecture = get_architecture()?; let architecture = get_architecture()?;
let result = format!("{} {} ({})", system, kernel_release, architecture); let result = format!("{system} {kernel_release} ({architecture})");
Ok(result) Ok(result)
} }

View file

@ -13,7 +13,7 @@ pub fn get_username_and_hostname() -> Result<String, io::Error> {
let output = Command::new("hostname").output()?; let output = Command::new("hostname").output()?;
let hostname = String::from_utf8_lossy(&output.stdout).trim().to_string(); 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<String, Box<dyn std::error::Error>> { pub fn get_root_disk_usage() -> Result<String, Box<dyn std::error::Error>> {
@ -30,8 +30,7 @@ pub fn get_root_disk_usage() -> Result<String, Box<dyn std::error::Error>> {
let usage_percentage = (used_size as f64 / total_size as f64) * 100.0; let usage_percentage = (used_size as f64 / total_size as f64) * 100.0;
Ok(format!( Ok(format!(
"{:.2} GiB / {:.2} GiB ({CYAN}{:.0}%{RESET})", "{used_size_gib:.2} GiB / {total_size_gib:.2} GiB ({CYAN}{usage_percentage:.0}%{RESET})"
used_size_gib, total_size_gib, usage_percentage
)) ))
} }
@ -78,7 +77,6 @@ pub fn get_memory_usage() -> Result<String, io::Error> {
let percentage_used = (used_memory / total_memory * 100.0).round() as u64; let percentage_used = (used_memory / total_memory * 100.0).round() as u64;
Ok(format!( Ok(format!(
"{:.2} GiB / {:.2} GiB ({CYAN}{}%{RESET})", "{used_memory:.2} GiB / {total_memory:.2} GiB ({CYAN}{percentage_used}%{RESET})"
used_memory, total_memory, percentage_used
)) ))
} }

View file

@ -27,15 +27,15 @@ pub fn get_system_uptime() -> Result<String, io::Error> {
let mut parts = Vec::new(); let mut parts = Vec::new();
if days > 0 { if days > 0 {
parts.push(format!("{} days", days)); parts.push(format!("{days} days"));
} }
if hours > 0 || days > 0 { if hours > 0 || days > 0 {
parts.push(format!("{} hours", hours)); parts.push(format!("{hours} hours"));
} }
if minutes > 0 || hours > 0 || days > 0 { if minutes > 0 || hours > 0 || days > 0 {
parts.push(format!("{} minutes", minutes)); parts.push(format!("{minutes} minutes"));
} }
Ok(parts.join(", ")) Ok(parts.join(", "))