Created
September 14, 2015 15:33
-
-
Save archer884/660560ebf14ae675c15e to your computer and use it in GitHub Desktop.
Read function that doesn't return newline characters
This file contains hidden or 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 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