Skip to content

Instantly share code, notes, and snippets.

@archer884
Created September 14, 2015 15:33
Show Gist options
  • Save archer884/660560ebf14ae675c15e to your computer and use it in GitHub Desktop.
Save archer884/660560ebf14ae675c15e to your computer and use it in GitHub Desktop.
Read function that doesn't return newline characters
fn read() -> String {
let mut buffer = String::new();
std::io::stdin().read_line(&mut buffer).ok();
if buffer.ends_with("\n") {
buffer.pop();
}
if buffer.ends_with("\r") {
buffer.pop();
}
buffer
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment