Skip to content

std: Add a note about the print! macro and output buffering - #23826

Merged
bors merged 1 commit into
rust-lang:masterfrom
richo:note-print-macro
Mar 31, 2015
Merged

std: Add a note about the print! macro and output buffering#23826
bors merged 1 commit into
rust-lang:masterfrom
richo:note-print-macro

Conversation

@richo

Copy link
Copy Markdown
Contributor

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

Comment threadsrc/libstd/macros.rs Outdated

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
ContributorAuthor

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!

@tanadeau

Copy link
Copy Markdown
Contributor

It would be helpful if this had a reference to the flush() method on the Write trait and an example of the use of print! that needs flushing (like a prompt).

Comment threadsrc/libstd/macros.rs Outdated

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
ContributorAuthor

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)

Copy link
Copy Markdown
Member

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)

@richo

Copy link
Copy Markdown
ContributorAuthor

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.

Comment threadsrc/libstd/macros.rs Outdated

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
ContributorAuthor

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.

@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+ 6e8693b rollup

Thanks!

bors added a commit that referenced this pull request Mar 31, 2015
@bors
bors merged commit 6e8693b into rust-lang:masterMar 31, 2015
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@richo@rust-highfive@tanadeau@alexcrichton@barosl@huonw@bors