use crate::How; mod private { use crate::How; #[doc(hidden)] pub trait IntoResultHow: Sized { type T; fn into_result_how(self) -> Result; } } pub(crate) use private::IntoResultHow; impl IntoResultHow for Result where E: std::error::Error, { type T = T; #[inline(always)] fn into_result_how(self) -> Result { #[inline(never)] fn into(e: E) -> How { How::new(e.to_string()) } self.map_err(into) } } impl IntoResultHow for Result { type T = T; #[inline(always)] fn into_result_how(self) -> Result { self } } impl IntoResultHow for Option { type T = T; #[inline(always)] fn into_result_how(self) -> Result { #[inline(never)] fn into() -> How { How::new("Option::None") } self.ok_or_else(into) } }