Created
June 23, 2016 11:23
-
-
Save kbrgl/143f143f9047c921d64ee05b0434f0cd to your computer and use it in GitHub Desktop.
This file contains 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
fn input() -> io::Result<String> { | |
let mut string = String::new(); | |
let bytes_read = try!(io::stdin().read_line(&mut string)); | |
if bytes_read == 0 { | |
return Err(io::Error::new(io::ErrorKind::Other, | |
"The line could not be read.")); | |
} | |
string = string.trim_right_matches("\r\n").to_owned(); | |
string = string.trim_right_matches("\n").to_owned(); | |
return Ok(string); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment