use io_enum::*; enum Enum { A(A), B(B), } impl ::std::io::Read for Enum where A: ::std::io::Read, B: ::std::io::Read, { #[inline] fn read(&mut self, buf: &mut [u8]) -> ::std::io::Result { match self { Enum::A(x) => ::read(x, buf), Enum::B(x) => ::read(x, buf), } } #[inline] fn read_vectored( &mut self, bufs: &mut [::std::io::IoSliceMut<'_>], ) -> ::std::io::Result { match self { Enum::A(x) => ::read_vectored(x, bufs), Enum::B(x) => ::read_vectored(x, bufs), } } #[inline] fn read_to_end( &mut self, buf: &mut ::std::vec::Vec, ) -> ::std::io::Result { match self { Enum::A(x) => ::read_to_end(x, buf), Enum::B(x) => ::read_to_end(x, buf), } } #[inline] fn read_to_string( &mut self, buf: &mut ::std::string::String, ) -> ::std::io::Result { match self { Enum::A(x) => ::read_to_string(x, buf), Enum::B(x) => ::read_to_string(x, buf), } } #[inline] fn read_exact(&mut self, buf: &mut [u8]) -> ::std::io::Result<()> { match self { Enum::A(x) => ::read_exact(x, buf), Enum::B(x) => ::read_exact(x, buf), } } } fn main() {}