1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
use std::io::{Read, Write, stdout, stdin, Error}; use std::collections::{HashMap}; pub struct Printer {} impl Printer { pub fn print(message: &str) -> Result<(), Error>{ stdout().write(message.as_bytes())?; Ok(()) } } pub struct Reader {} impl Reader { pub fn input(buff: &mut String) -> Result<(), HashMap<i32, &str>> { stdout().flush().unwrap(); { let stdin = stdin(); match stdin.read_line(buff) { Ok(_) => Ok(()), _ => {let mut output = HashMap::new(); output.insert(0x01, "Could read data"); Err(output)}, } } } }