Show prompt on same line

This commit is contained in:
~karx 2021-04-07 17:02:39 -05:00
parent 285ff4c8c6
commit dcef0a3943
No known key found for this signature in database
GPG Key ID: A794DA2529474BA5
1 changed files with 3 additions and 1 deletions

View File

@ -1,4 +1,5 @@
use std::io;
use std::io::Write;
pub fn do_math(arguments: String, operator: char) -> u32 {
let split_args = arguments.split("-").collect::<Vec<&str>>();
@ -38,7 +39,8 @@ pub fn args_or_comments(arguments: &str) -> String {
}
pub fn read_stdin(prompt: &str) -> String {
println!("{}", prompt);
print!("{}", prompt);
io::stdout().flush().unwrap();
let mut result = String::new();
io::stdin().read_line(&mut result).expect("Expected a string!");