Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/assets/ascii_art/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/info/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -236,4 +236,4 @@ impl Inject for Cpu {
Err(e) => { errors::handle(&format!("{}{}", errors::LUA, e)); panic!(); }
}
}
}
}
4 changes: 2 additions & 2 deletions src/info/distro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 )
}
}
}
6 changes: 3 additions & 3 deletions src/info/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Gpus {
let regex = Regex::new(r#"(?i)"(.*?(?:Display|3D|VGA).*?)" "(.*?\[.*?\])" "(?:.*?\[(.*?)\])""#).unwrap();
let lspci_lines = lspci.split("\n").collect::<Vec<&str>>();
for line in lspci_lines.iter() {
let captures = regex.captures(&line);
let captures = regex.captures(line);
match captures {
Some(captures) => {
to_return.push((
Expand Down Expand Up @@ -141,15 +141,15 @@ 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(),
brand));
}
}

if to_return.len() >= 1 {
if !to_return.is_empty() {
Some(Gpus(to_return))
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion src/info/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down
46 changes: 22 additions & 24 deletions src/info/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<&str>>();
let modes_lines = modes_string
.split("\n")
.collect::<Vec<&str>>();

for line in modes_lines.iter() {
let line_split = line
.split("x")
.collect::<Vec<&str>>();
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::<u16>().unwrap(),
height: height.unwrap().parse::<u16>().unwrap(),
refresh: None,
});
}
for line in modes_lines.iter() {
let line_split = line
.split("x")
.collect::<Vec<&str>>();
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::<u16>().unwrap(),
height: height.unwrap().parse::<u16>().unwrap(),
refresh: None,
});
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/info/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) struct Grep {
fn grep(through: Vec<String>, conf: Grep) -> Vec<String> {
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;
Expand Down Expand Up @@ -52,7 +52,7 @@ impl PsAux {
PsAux({
let mut to_return: Vec<String> = 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
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/info/wm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Wm {
panic!();
}
};
if stdout != "" {
if !stdout.is_empty() {
Some(Wm(stdout))
} else {
None
Expand Down