Skip to content

Instantly share code, notes, and snippets.

@kbrgl
Created June 23, 2016 11:23
Show Gist options
  • Save kbrgl/143f143f9047c921d64ee05b0434f0cd to your computer and use it in GitHub Desktop.
Save kbrgl/143f143f9047c921d64ee05b0434f0cd to your computer and use it in GitHub Desktop.
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