use std::error::Error; use std::fmt; use std::result; use std::io; pub type Result = result::Result; #[derive(Debug)] pub struct MeliError { details: String } impl MeliError { pub fn new(msg: M) -> MeliError where M: Into { MeliError{details: msg.into()} } } impl fmt::Display for MeliError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f,"{}",self.details) } } impl Error for MeliError { fn description(&self) -> &str { &self.details } } impl From for MeliError { #[inline] fn from(kind: io::Error) -> MeliError { MeliError::new(kind.description()) } }