Created
June 28, 2015 17:21
-
-
Save kudrevatykh/32b33c642998fea945a8 to your computer and use it in GitHub Desktop.
flush example
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
use std::io; | |
use std::io::Write; | |
fn main() { | |
let s = read_string("aaa"); | |
println!("inputed {}", s); | |
} | |
fn read_string(comment: &str) -> String { | |
print!("{}", comment); | |
io::stdout().flush().ok().expect("Error flushing"); | |
let mut string: String = String::new(); | |
std::io::stdin().read_line(&mut string) | |
.ok() | |
.expect("Error read line!"); | |
return string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment