From b3860dfb28cf8f974f1c066802ee6ce54c559ad0 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Fri, 1 Dec 2017 08:36:38 -0600 Subject: [PATCH] Update root helpers.rs --- helpers.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 helpers.rs diff --git a/helpers.rs b/helpers.rs new file mode 100644 index 0000000..bb4d915 --- /dev/null +++ b/helpers.rs @@ -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()); +}