From: Stephen Seo Date: Sun, 10 Jul 2022 04:13:57 +0000 (+0900) Subject: Refactor error handling in proc.rs X-Git-Tag: 0.1.0~22 X-Git-Url: https://git.seodisparate.com/stephenseo/static/git-favicon.png?a=commitdiff_plain;h=ed8d0b3f310d7a2579c027e5398bc1b72263c2be;p=swaybar_info Refactor error handling in proc.rs --- diff --git a/src/proc.rs b/src/proc.rs index 68dc1b8..e36ba49 100644 --- a/src/proc.rs +++ b/src/proc.rs @@ -1,6 +1,5 @@ use std::fmt::Write; use std::fs::File; -use std::io; use std::io::prelude::*; #[derive(Debug)] @@ -153,17 +152,13 @@ pub fn get_meminfo() -> Result { .split_whitespace() .map(|s| s.to_owned()) .collect::>(); - total = line_parts[1] - .parse() - .map_err(|_| io::Error::new(io::ErrorKind::Other, "MemTotal: parse error"))?; + total = line_parts[1].parse()?; } else if line.starts_with("MemAvailable:") { let line_parts = line .split_whitespace() .map(|s| s.to_owned()) .collect::>(); - available = line_parts[1] - .parse() - .map_err(|_| io::Error::new(io::ErrorKind::Other, "MemAvailable: parse error"))?; + available = line_parts[1].parse()?; } }