Combine the two Error impl blocks together

We have two impl blocks for `Error`, just squash them together into a
single one.
This commit is contained in:
Tobin C. Harding 2023-11-28 12:12:34 +11:00
parent 82ea4ff31d
commit b1870656c9
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 10 additions and 10 deletions

View File

@ -27,6 +27,16 @@ impl Error {
} }
pub fn kind(&self) -> ErrorKind { self.kind } 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<ErrorKind> for Error { impl From<ErrorKind> 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")] #[cfg(feature = "std")]
impl From<std::io::Error> for Error { impl From<std::io::Error> for Error {
fn from(o: std::io::Error) -> Error { fn from(o: std::io::Error) -> Error {