2017 Day 01 Complete in Rust

This commit is contained in:
2017-12-01 08:04:46 -06:00
parent 36e2202023
commit 09b1c9740d
3 changed files with 68 additions and 1 deletions

20
2017/day01/helpers.rs Normal file
View File

@@ -0,0 +1,20 @@
use std::io;
pub fn read_std_in() -> String {
let mut input = String::new();
let mut done = false;
while !done {
match io::stdin().read_line(&mut input) {
Ok(n) => {
if n == 0 {
done = true;
}
},
Err(error) => {
println!("error: {}", error);
done = true;
},
}
}
return String::from(input.trim());
}