diff --git a/io/src/error.rs b/io/src/error.rs index c2d18a2a..8d0a894d 100644 --- a/io/src/error.rs +++ b/io/src/error.rs @@ -27,6 +27,16 @@ impl Error { } pub fn kind(&self) -> ErrorKind { self.kind } + + #[cfg(feature = "std")] + pub fn get_ref(&self) -> Option<&(dyn std::error::Error + Send + Sync + 'static)> { + self.error.as_deref() + } + + #[cfg(all(feature = "alloc", not(feature = "std")))] + pub fn get_ref(&self) -> Option<&(dyn Debug + Send + Sync + 'static)> { + self.error.as_deref() + } } impl From for Error { @@ -70,16 +80,6 @@ impl std::error::Error for Error { } } -impl Error { - #[cfg(feature = "std")] - pub fn get_ref(&self) -> Option<&(dyn std::error::Error + Send + Sync + 'static)> { - self.error.as_deref() - } - - #[cfg(all(feature = "alloc", not(feature = "std")))] - pub fn get_ref(&self) -> Option<&(dyn Debug + Send + Sync + 'static)> { self.error.as_deref() } -} - #[cfg(feature = "std")] impl From for Error { fn from(o: std::io::Error) -> Error {