use auto_enums::enum_derive; enum Enum { A(A), B(B), } 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), } } } fn main() {}