error: implement From<Error> for io::Error

This commit is contained in:
meh 2015-09-22 04:03:49 +02:00
parent 1fc224fbae
commit 316778ccd9

View File

@ -1,4 +1,5 @@
use std::error;
use std::io;
use std::fmt;
use std::ffi::CStr;
use std::str::from_utf8_unchecked;
@ -110,6 +111,12 @@ impl Into<c_int> for Error {
}
}
impl From<Error> for io::Error {
fn from(value: Error) -> io::Error {
io::Error::new(io::ErrorKind::Other, value)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
f.write_str(error::Error::description(self))