Refactorings
This commit is contained in:
parent
5a16bc7ba0
commit
35e4332e2f
2 changed files with 11 additions and 13 deletions
18
src/main.rs
18
src/main.rs
|
@ -94,14 +94,13 @@ fn main() {
|
|||
// meminfo
|
||||
{
|
||||
let meminfo_result = proc::get_meminfo();
|
||||
let meminfo_string: String;
|
||||
if let Err(e) = meminfo_result {
|
||||
let meminfo_string: String = if let Err(e) = meminfo_result {
|
||||
let mut stderr_handle = io::stderr().lock();
|
||||
stderr_handle.write_all(format!("{}\n", e).as_bytes()).ok();
|
||||
meminfo_string = String::from("MEMINFO ERROR");
|
||||
String::from("MEMINFO ERROR")
|
||||
} else {
|
||||
meminfo_string = meminfo_result.unwrap();
|
||||
}
|
||||
meminfo_result.unwrap()
|
||||
};
|
||||
let meminfo_obj = SwaybarObject::from_string(meminfo_string);
|
||||
array.push_object(meminfo_obj);
|
||||
}
|
||||
|
@ -109,14 +108,13 @@ fn main() {
|
|||
// loadavg
|
||||
{
|
||||
let loadavg_result = proc::get_loadavg();
|
||||
let loadavg_string: String;
|
||||
if let Err(e) = loadavg_result {
|
||||
let loadavg_string: String = if let Err(e) = loadavg_result {
|
||||
let mut stderr_handle = io::stderr().lock();
|
||||
stderr_handle.write_all(format!("{}\n", e).as_bytes()).ok();
|
||||
loadavg_string = String::from("LOADAVG ERROR");
|
||||
String::from("LOADAVG ERROR")
|
||||
} else {
|
||||
loadavg_string = loadavg_result.unwrap();
|
||||
}
|
||||
loadavg_result.unwrap()
|
||||
};
|
||||
let loadavg_obj = SwaybarObject::from_string(loadavg_string);
|
||||
array.push_object(loadavg_obj);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ impl std::error::Error for Error {
|
|||
Error::IO(e) => e.source(),
|
||||
Error::ParseInt(e) => e.source(),
|
||||
Error::Format(e) => e.source(),
|
||||
_ => None,
|
||||
Error::Generic(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,10 +83,10 @@ impl NetInfo {
|
|||
netdev_file.read_to_string(&mut netdev_string)?;
|
||||
}
|
||||
|
||||
let mut dev_line: Option<String> = None;
|
||||
let mut dev_line: Option<&str> = None;
|
||||
for line in netdev_string.lines() {
|
||||
if line.starts_with(&self.dev_name) {
|
||||
dev_line = Some(line.to_owned());
|
||||
dev_line = Some(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue