use auto_enums::enum_derive; enum Enum { A(A), B(B), } impl ::core::fmt::Display for Enum where A: ::core::fmt::Display, B: ::core::fmt::Display, { #[inline] fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { match self { Enum::A(x) => ::fmt(x, f), Enum::B(x) => ::fmt(x, f), } } } impl ::core::fmt::Debug for Enum where A: ::core::fmt::Debug, B: ::core::fmt::Debug, { #[inline] fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { match self { Enum::A(x) => ::fmt(x, f), Enum::B(x) => ::fmt(x, f), } } } impl ::std::error::Error for Enum where A: ::std::error::Error, B: ::std::error::Error, A: 'static, B: 'static, { #[allow(deprecated)] fn description(&self) -> &str { match self { Enum::A(x) => ::description(x), Enum::B(x) => ::description(x), } } fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> { match self { Enum::A(x) => ::std::option::Option::Some(x), Enum::B(x) => ::std::option::Option::Some(x), } } } fn main() {}