From 64249e0f672dcaeb2bbc47b3ace60f78ba83f07a Mon Sep 17 00:00:00 2001 From: emma Date: Fri, 14 Apr 2023 14:53:55 -0400 Subject: [PATCH] minor fixes to main() --- src/main.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index d19a1b9..0e3a5a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -472,12 +472,12 @@ fn main() -> Result<()> { if unsafe { libc::isatty(stdin) } == 0 { unsafe { File::from_raw_fd(stdin) } } else { - File::open("/dev/null").unwrap() + File::open("/dev/null")? } } Some(path) => { let input_file = Path::new(path); - file_name = Some(OsString::from(input_file.clone().display().to_string())); + file_name = Some(OsString::from(&path)); File::open(input_file).unwrap_or_else(|_| { let mut err = String::new(); @@ -491,8 +491,7 @@ fn main() -> Result<()> { }) } } - .read_to_end(&mut buf) - .unwrap(); + .read_to_end(&mut buf)?; let text = String::from_utf8(buf).unwrap_or_else(|_| { eprintln!(