diff --git a/src/assets/ascii_art/mod.rs b/src/assets/ascii_art/mod.rs index 3c7cf34..a33e8ec 100644 --- a/src/assets/ascii_art/mod.rs +++ b/src/assets/ascii_art/mod.rs @@ -294,21 +294,21 @@ pub(crate) fn get(of: &str) -> (&'static str, [Option<&'static str>; 4]) { if art.2.is_none() { if of.to_lowercase() == art.0.to_lowercase() { return get_tuple(); } } else { - if of.to_lowercase() == art.2.clone().unwrap().to_lowercase() { return get_tuple(); } + if of.to_lowercase() == art.2.unwrap().to_lowercase() { return get_tuple(); } } } Check::Contains => { if art.2.is_none() { if of.to_lowercase().contains(&art.0.to_lowercase()) { return get_tuple(); } } else { - if of.contains(&art.2.clone().unwrap()) { return get_tuple(); } + if of.contains(&art.2.unwrap()) { return get_tuple(); } } } Check::StartsWith => { if art.2.is_none() { if of.to_lowercase().starts_with(&art.0.to_lowercase()) { return get_tuple(); } } else { - if of.to_lowercase().starts_with(&art.2.clone().unwrap().to_lowercase()) { return get_tuple(); } + if of.to_lowercase().starts_with(&art.2.unwrap().to_lowercase()) { return get_tuple(); } } } } diff --git a/src/build.rs b/src/build.rs index 9021af1..1a590b3 100644 --- a/src/build.rs +++ b/src/build.rs @@ -21,7 +21,7 @@ fn get_buildlist(base: &Path) -> BuildList { let mut to_return = Vec::new(); for line in split.iter() { if !line.starts_with("#") { - to_return.push(line.clone()); + to_return.push(*line); } } to_return diff --git a/src/info/cpu.rs b/src/info/cpu.rs index b00add3..a525de9 100644 --- a/src/info/cpu.rs +++ b/src/info/cpu.rs @@ -196,9 +196,9 @@ impl Cpu { to_return = String::from(to_return.trim()); to_return }, - full_name: name.clone().unwrap(), - freq: freq.clone().unwrap(), - cores: cores.clone().unwrap(), + full_name: name.unwrap(), + freq: freq.unwrap(), + cores: cores.unwrap(), }) } else { None @@ -236,4 +236,4 @@ impl Inject for Cpu { Err(e) => { errors::handle(&format!("{}{}", errors::LUA, e)); panic!(); } } } -} \ No newline at end of file +} diff --git a/src/info/distro.rs b/src/info/distro.rs index 9235825..1cf3aa6 100644 --- a/src/info/distro.rs +++ b/src/info/distro.rs @@ -32,7 +32,7 @@ impl Distro { "Linux"|"BSD"|"MINIX" => { // Bedrock Linux if Path::new("/bedrock/etc/bedrock-release").exists() - && env::var("PATH").unwrap_or(String::new()).contains("/bedrock/cross/") { + && env::var("PATH").unwrap_or_default().contains("/bedrock/cross/") { long_name = fs::read_to_string("/bedrock/etc/bedrock-release") .unwrap_or(String::from("Bedrock Linux")); short_name = String::from("Bedrock Linux"); @@ -182,4 +182,4 @@ impl From<[Option<&'static str>; 4]> for DistroColors { if _2 == "\u{001b}[38;5;7m" { _2 = _1.clone(); } DistroColors ( _1, _2, _3, _4 ) } -} \ No newline at end of file +} diff --git a/src/info/gpu.rs b/src/info/gpu.rs index 5b39a78..f26db73 100644 --- a/src/info/gpu.rs +++ b/src/info/gpu.rs @@ -73,7 +73,7 @@ impl Gpus { let regex = Regex::new(r#"(?i)"(.*?(?:Display|3D|VGA).*?)" "(.*?\[.*?\])" "(?:.*?\[(.*?)\])""#).unwrap(); let lspci_lines = lspci.split("\n").collect::>(); for line in lspci_lines.iter() { - let captures = regex.captures(&line); + let captures = regex.captures(line); match captures { Some(captures) => { to_return.push(( @@ -141,7 +141,7 @@ impl Gpus { String::from(regex.replace(&brand, "Intel HD Graphics")) }; brand = String::from(brand.trim()); - if brand == "" { brand = String::from("Intel HD Graphics"); } + if brand.is_empty() { brand = String::from("Intel HD Graphics"); } to_return.push( Gpu::new( gpu.2.clone(), @@ -149,7 +149,7 @@ impl Gpus { } } - if to_return.len() >= 1 { + if !to_return.is_empty() { Some(Gpus(to_return)) } else { None diff --git a/src/info/host.rs b/src/info/host.rs index 669b873..976ba2e 100644 --- a/src/info/host.rs +++ b/src/info/host.rs @@ -40,7 +40,7 @@ impl Host { product_name = String::from(regex.replace_all(&product_name, "")); } product_name = String::from(product_name.trim()); - if product_name != "" { + if !product_name.is_empty() { Some(Host { model: product_name, }) diff --git a/src/info/resolution.rs b/src/info/resolution.rs index 0a689d2..21377cb 100644 --- a/src/info/resolution.rs +++ b/src/info/resolution.rs @@ -188,32 +188,30 @@ impl Resolution { } } else if Path::new("/sys/class/drm/").is_dir() { if let Ok(entries) = Path::new("/sys/class/drm/").read_dir() { - for entry in entries { - if let Ok(entry) = entry { - if entry.path().join("modes").is_file() { - let modes_string = match read_to_string(entry.path().join("modes")) { - Ok(modes) => modes, - Err(_) => return None, - }; + for entry in entries.flatten() { + if entry.path().join("modes").is_file() { + let modes_string = match read_to_string(entry.path().join("modes")) { + Ok(modes) => modes, + Err(_) => return None, + }; - let modes_lines = modes_string - .split("\n") - .collect::>(); + let modes_lines = modes_string + .split("\n") + .collect::>(); - for line in modes_lines.iter() { - let line_split = line - .split("x") - .collect::>(); - let width = line_split.get(0); - let height = line_split.get(1); - if width.is_some() - && height.is_some() { - return Some(Resolution { - width: width.unwrap().parse::().unwrap(), - height: height.unwrap().parse::().unwrap(), - refresh: None, - }); - } + for line in modes_lines.iter() { + let line_split = line + .split("x") + .collect::>(); + let width = line_split.get(0); + let height = line_split.get(1); + if width.is_some() + && height.is_some() { + return Some(Resolution { + width: width.unwrap().parse::().unwrap(), + height: height.unwrap().parse::().unwrap(), + refresh: None, + }); } } } diff --git a/src/info/utils.rs b/src/info/utils.rs index 469abd1..341a72a 100644 --- a/src/info/utils.rs +++ b/src/info/utils.rs @@ -21,7 +21,7 @@ pub(crate) struct Grep { fn grep(through: Vec, conf: Grep) -> Vec { let mut conf = conf.clone(); if conf.searches.is_none() && conf.search.is_some() { conf.searches = Some(vec![conf.search.clone().unwrap()]); } - if conf.searches.is_none() { return vec![]; } + if conf.searches.is_none() { vec![] } else { let mut to_return = Vec::new(); let mut i = 0usize; @@ -52,7 +52,7 @@ impl PsAux { PsAux({ let mut to_return: Vec = Vec::new(); let system = get_system(); - for (_, proc) in system.processes() { to_return.push(String::from(proc.name())); } + for proc in system.processes().values() { to_return.push(String::from(proc.name())); } to_return }) } diff --git a/src/info/wm.rs b/src/info/wm.rs index 6c3fdd4..35e2aa4 100644 --- a/src/info/wm.rs +++ b/src/info/wm.rs @@ -79,7 +79,7 @@ impl Wm { panic!(); } }; - if stdout != "" { + if !stdout.is_empty() { Some(Wm(stdout)) } else { None