Skip to content

Commit b814b2b

Browse files
refactor: return write error
1 parent 0233cdc commit b814b2b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2727
storage: get_root_disk_usage()?,
2828
colors: print_dots(),
2929
};
30-
print_system_info(&fields);
30+
print_system_info(&fields)?;
3131
}
3232

3333
Ok(())
@@ -49,7 +49,7 @@ struct Fields {
4949
colors: String,
5050
}
5151

52-
fn print_system_info(fields: &Fields) {
52+
fn print_system_info(fields: &Fields) -> Result<(), Box<dyn std::error::Error>> {
5353
use crate::colors::COLORS;
5454

5555
let Fields {
@@ -78,7 +78,5 @@ fn print_system_info(fields: &Fields) {
7878
{blue} ▝ {cyan}▟█▜█▖{blue}▀▀▀▀▀██▛▀▀▘ {cyan}󱥎 {blue}Storage (/){reset}  {storage}
7979
{cyan} ▟█▘ ▜█▖ {blue}▝█▛ {cyan} {blue}Colors{reset}  {colors}\n");
8080

81-
stdout()
82-
.write_all(system_info.as_bytes())
83-
.expect("Failed to write to stdout");
81+
Ok(stdout().write_all(system_info.as_bytes())?)
8482
}

0 commit comments

Comments
 (0)