generalize impl_error! macro so that used for other errors type

This commit is contained in:
Riccardo Casatta
2020-12-04 11:23:01 +01:00
parent 586b874a19
commit 81519555cf
4 changed files with 16 additions and 51 deletions

View File

@@ -110,9 +110,12 @@ impl std::error::Error for Error {}
macro_rules! impl_error {
( $from:ty, $to:ident ) => {
impl std::convert::From<$from> for Error {
impl_error!($from, $to, Error);
};
( $from:ty, $to:ident, $impl_for:ty ) => {
impl std::convert::From<$from> for $impl_for {
fn from(err: $from) -> Self {
Error::$to(err)
<$impl_for>::$to(err)
}
}
};