Skip to content

Commit 456276b

Browse files
Stebaliensamuelburnham
authored andcommitted
simplify core2 imports
We can avoid some duplicate code if we alias.
1 parent 4623728 commit 456276b

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/error.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(not(feature = "std"))]
2-
use core2::io::Error as IoError;
2+
use core2::{error::Error as StdError, io::Error as IoError};
33
#[cfg(feature = "std")]
4-
use std::io::Error as IoError;
4+
use std::{error::Error as StdError, io::Error as IoError};
55

66
use unsigned_varint::decode::Error as DecodeError;
77
#[cfg(feature = "std")]
@@ -32,20 +32,8 @@ impl core::fmt::Display for Error {
3232
}
3333
}
3434

35-
#[cfg(feature = "std")]
36-
impl std::error::Error for Error {}
37-
38-
#[cfg(not(feature = "std"))]
39-
impl core2::error::Error for Error {}
35+
impl StdError for Error {}
4036

41-
#[cfg(not(feature = "std"))]
42-
impl From<core2::io::Error> for Error {
43-
fn from(err: core2::io::Error) -> Self {
44-
Self::Io(err)
45-
}
46-
}
47-
48-
#[cfg(feature = "std")]
4937
impl From<IoError> for Error {
5038
fn from(err: IoError) -> Self {
5139
Self::Io(err)

0 commit comments

Comments
 (0)