diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2020-05-24 15:52:35 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2020-05-24 15:52:35 +0200 |
commit | daf595fe5648250c2947947ba5d9cdf4ab24b403 (patch) | |
tree | 7673660a3f8223cc4b82b65176d708adb8fb5d02 | |
parent | 806ba1d0a866da7a60ca4e94b7209e85250e396c (diff) | |
download | neco-daf595fe5648250c2947947ba5d9cdf4ab24b403.tar neco-daf595fe5648250c2947947ba5d9cdf4ab24b403.zip |
stdio: nicer error handling
-rw-r--r-- | safe_libc/src/stdio.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/safe_libc/src/stdio.rs b/safe_libc/src/stdio.rs index be016ab..2942405 100644 --- a/safe_libc/src/stdio.rs +++ b/safe_libc/src/stdio.rs @@ -7,6 +7,12 @@ pub struct Error { pub errno: errno::Errno, } +impl From<Error> for fmt::Error { + fn from(_err: Error) -> fmt::Error { + fmt::Error + } +} + pub type Result<T> = core::result::Result<T, Error>; #[inline] @@ -58,9 +64,7 @@ impl BasicOStream { impl fmt::Write for BasicOStream { #[inline] fn write_str(&mut self, s: &str) -> fmt::Result { - if self.write(s.as_bytes()).is_err() { - return Err(fmt::Error); - } + self.write(s.as_bytes())?; Ok(()) } } |