stdio: nicer error handling
This commit is contained in:
parent
806ba1d0a8
commit
daf595fe56
1 changed files with 7 additions and 3 deletions
|
@ -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(())
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue