rust-lang / rust-lang/rust

Document buffering behaviour fot `Stdout(Lock)`

Open
#137,628 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-docs A-io T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Location
Summary

The handles provided by std::io::stdout() are line-buffered, but there is nothing in the documentation suggesting this. The only mention of buffering for stdout in the documentation is the line

Each handle shares a global buffer of data to be written to the standard output stream. Access is also synchronized via a lock and explicit control over locking is available via the lock method.

I don't think this is very clear that stdout is buffered from this, nor that it uses line buffering.

Moreover, the comments for LineWriterShim suggest that this mechanism can be used to alternate between line buffering and block buffering for Stdout, which isn't mentioned in the documentation for Stdout at all.

I do not mean to relitigate whether or not it should be buffered (previous discussion in https://github.com/rust-lang/rust/issues/23818) but I'd like to clarify how it is buffered, and how one should deal with it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Stdout and StdoutLock documentation, then read the referenced LineWriterShim comments and the prior buffering discussion. Update the documentation to explain how stdout is buffered and how callers should deal with that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.