use auto_enums::enum_derive; enum Enum { A(A), B(B), } impl ::std::io::Write for Enum where A: ::std::io::Write, B: ::std::io::Write, { #[inline] fn write(&mut self, buf: &[u8]) -> ::std::io::Result { match self { Enum::A(x) => ::write(x, buf), Enum::B(x) => ::write(x, buf), } } #[inline] fn write_vectored( &mut self, bufs: &[::std::io::IoSlice<'_>], ) -> ::std::io::Result { match self { Enum::A(x) => ::write_vectored(x, bufs), Enum::B(x) => ::write_vectored(x, bufs), } } #[inline] fn flush(&mut self) -> ::std::io::Result<()> { match self { Enum::A(x) => ::flush(x), Enum::B(x) => ::flush(x), } } #[inline] fn write_all(&mut self, buf: &[u8]) -> ::std::io::Result<()> { match self { Enum::A(x) => ::write_all(x, buf), Enum::B(x) => ::write_all(x, buf), } } #[inline] fn write_fmt(&mut self, fmt: ::std::fmt::Arguments<'_>) -> ::std::io::Result<()> { match self { Enum::A(x) => ::write_fmt(x, fmt), Enum::B(x) => ::write_fmt(x, fmt), } } } fn main() {}