-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std: Add a note about the print! macro and output buffering #23826
Conversation
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -64,6 +64,9 @@ macro_rules! panic { | |||
/// | |||
/// Equivalent to the `println!` macro except that a newline is not printed at | |||
/// the end of the message. | |||
/// | |||
/// Note that because stdout is by default unbuffered on unix systems, this may |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be buffered instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err, yeah. Thanks for the catch!
It would be helpful if this had a reference to the |
@@ -64,6 +64,9 @@ macro_rules! panic { | |||
/// | |||
/// Equivalent to the `println!` macro except that a newline is not printed at | |||
/// the end of the message. | |||
/// | |||
/// Note that because stdout is by default buffered on unix systems, this may | |||
/// result in output not being emitted until stdout is flushed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may want to be rephrased to not mention unix and also mention "line buffering" somewhere, perhaps:
Note that stdout is frequently line-buffered by default so it may be necessary to use
io::stdout().flush()
to ensure the output is emitted immediately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally reasonable, is there markup to make it actually linkify io::stdout
? (Will it do this by default? That would be amazing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, no, there is no default auto-linking, but you can always do it manually via [foo](../bar/baz.html)
I updated the doc comment. Including the link inline made it no longer possible to just copy the invocation out of the comment, which I felt outweighed the benefit. |
@@ -64,6 +64,9 @@ macro_rules! panic { | |||
/// | |||
/// Equivalent to the `println!` macro except that a newline is not printed at | |||
/// the end of the message. | |||
/// | |||
/// Note that stdout is frequently line-buffered by default so it may be necessary to use | |||
/// io::stdout().flush() to ensure the output is emitted immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you match the surrounding style and wrap this to 80-characters as well? Also, can you put io::stdout().flush()
in backticks as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, apologies somehow tw
got screwed up in my editor.
cc #23818