Created
February 19, 2016 03:35
-
-
Save habnabit/5594ccb833bd7e42f704 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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