-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
As stdout is line-buffered, stdout is not implicitly flushed until a new-line is encountered. This means that the print!
macro does not act like a println!
without the newline as the documentation suggests. To be equivalent, the user must explicitly flush stdout like the following:
use std::io::prelude::*;
use std::io;
fn main() {
print!("Type something: ");
io::stdout().flush().ok().expect("Could not flush stdout");
// Read stdin, etc.
}
For easy use of the print macros, the user should not need to know about how I/O flushing works. As such, print!
should explicitly flush stdout itself.
nivekuil, vlttnv, laundry-96, kirelagin, mark-i-m and 111 morestuartcrobinson, jkugelman, coolbreezechloe, lalitshankarch, Tanja-4732 and 3 moreCoffeelessProgrammer, lalitshankarch and cmlccie
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.