1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
/// Implements 'From' for a list of variants, intended for use with error enums
/// that are wrapping a number of errors from other methods.
#[macro_export]
macro_rules! impl_from {
    (
        $enum_name: ident {
            $($error_type: ty => $variant_name: ident),* $(,)*
        }
    ) => {
        $(
            impl From<$error_type> for $enum_name {
                fn from(error: $error_type) -> $enum_name {
                    $enum_name::$variant_name(error)
                }
            }
        )*
    }
}