use crate::StdError; use core::fmt::{self, Debug, Display}; #[cfg(backtrace)] use std::error::Request; #[repr(transparent)] pub struct MessageError(pub M); impl Debug for MessageError where M: Display + Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Debug::fmt(&self.0, f) } } impl Display for MessageError where M: Display + Debug, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Display::fmt(&self.0, f) } } impl StdError for MessageError where M: Display + Debug + 'static {} #[repr(transparent)] pub struct DisplayError(pub M); impl Debug for DisplayError where M: Display, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Display::fmt(&self.0, f) } } impl Display for DisplayError where M: Display, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Display::fmt(&self.0, f) } } impl StdError for DisplayError where M: Display + 'static {} #[cfg(feature = "std")] #[repr(transparent)] pub struct BoxedError(pub Box); #[cfg(feature = "std")] impl Debug for BoxedError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Debug::fmt(&self.0, f) } } #[cfg(feature = "std")] impl Display for BoxedError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Display::fmt(&self.0, f) } } #[cfg(feature = "std")] impl StdError for BoxedError { fn source(&self) -> Option<&(dyn StdError + 'static)> { self.0.source() } #[cfg(backtrace)] fn provide<'a>(&'a self, request: &mut Request<'a>) { self.0.provide(request); } }