summaryrefslogtreecommitdiffstats
path: root/safe_libc/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2020-05-24 15:52:35 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2020-05-24 15:52:35 +0200
commitdaf595fe5648250c2947947ba5d9cdf4ab24b403 (patch)
tree7673660a3f8223cc4b82b65176d708adb8fb5d02 /safe_libc/src
parent806ba1d0a866da7a60ca4e94b7209e85250e396c (diff)
downloadneco-daf595fe5648250c2947947ba5d9cdf4ab24b403.tar
neco-daf595fe5648250c2947947ba5d9cdf4ab24b403.zip
stdio: nicer error handling
Diffstat (limited to 'safe_libc/src')
-rw-r--r--safe_libc/src/stdio.rs10
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(())
}
}