use std::io::{self, Read, BufRead, BufReader}; use std::error::Error; use std::fmt; #[derive(Debug)] struct Content { a: u32, b: u32, s: String, } impl Content { fn from_reader(reader: R) -> Result> { let mut reader = BufReader::new(reader); let mut buf = String::new(); try!(reader.read_line(&mut buf)); let list: Vec<&str> = buf.trim().split(' ').collect(); let a: u32 = try!(list[0].parse()); let b: u32 = try!(list[1].parse()); let mut buf = String::new(); try!(reader.read_line(&mut buf)); Ok(Content { a: a, b: b, s: buf.trim().to_string(), }) } } impl fmt::Display for Content { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} {}", self.a + self.b, self.s) } } fn main() { let content = Content::from_reader(io::stdin()).unwrap(); println!("{}", content); }