Skip to content

Instantly share code, notes, and snippets.

@habnabit
Created February 19, 2016 03:35
Show Gist options
  • Save habnabit/5594ccb833bd7e42f704 to your computer and use it in GitHub Desktop.
Save habnabit/5594ccb833bd7e42f704 to your computer and use it in GitHub Desktop.
use std::io;
use std::io::BufRead;
fn do_the_work() -> io::Result<()> {
let stdin = io::stdin();
for line in stdin.lock().lines() {
let line = try!(line);
let splut: Result<Vec<i32>, _> = line.split(" ").map(|s| s.parse()).take(3).collect();
match splut {
Ok(ref v) if v.len() == 2 =>
println!("a - 1: {}; b * 2: {}", v[0] - 1, v[1] * 2),
_ => println!("unparsable line: {:?}", line),
}
}
Ok(())
}
fn main() {
do_the_work().unwrap();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment