macro_rules! implement_error_in_enum {
($enum_error:ident, $err_type: path, $enum_variant: path) => { ... };
}Expand description
Implement the From trait for an enum.
WARNING: you might prefer to use thiserror instead of this macro.
§Params
ⓘ
implement_error_in_enum!($type_, $err_type, $enum_variant);§Example
use std::fmt::Debug;
use std::io::Error;
use heimdall_errors::implement_error_in_enum;
pub (crate) enum EnumError {
IO(Error)
}
// Implement From<Error> for StructError.
implement_error_in_enum!(EnumError, Error, EnumError::IO);§Code generated
The code
ⓘ
implement_error_in_enum!(EnumError, Error, EnumError::IO);generates the next code
ⓘ
impl From<Error> for EnumError {
fn from(err: Error) -> Self {
EnumError::Io(err)
}
}