use std::io::{stdin, stdout, Read, Result, Stdin, Stdout, Write}; pub struct CombinedStdInOut { stdin: Stdin, stdout: Stdout, } impl CombinedStdInOut { pub fn new() -> CombinedStdInOut { CombinedStdInOut { stdin: stdin(), stdout: stdout(), } } } impl Read for CombinedStdInOut { fn read(&mut self, buf: &mut [u8]) -> Result { self.stdin.read(buf) } } impl Write for CombinedStdInOut { fn write(&mut self, buf: &[u8]) -> Result { let r = self.stdout.write(buf)?; Ok(r) } fn flush(&mut self) -> Result<()> { self.stdout.flush() } }