Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2346,10 +2346,19 @@ fn skip_until<R: BufRead + ?Sized>(r: &mut R, delim: u8) -> Result<usize> {
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "IoBufRead")]
pub trait BufRead: Read {
/// Returns the contents of the internal buffer, filling it with more data, via `Read` methods, if empty.
/// Returns the contents of the internal buffer, filling it with more data from the underlying reader if it is empty.
///
/// This function will not read data into the buffer if some is already present.
/// When calling this method, none of the contents will be "read" in the sense that later

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.

Perhaps this could use the same phrasing as used for consume below? So something like:

When calling this method, none of the contents will be marked as "read"...

/// calling [`read`] may return the same contents. As such, [`consume`] must be called
/// with the number of bytes that are consumed from this buffer to ensure that the
/// bytes are never returned twice.
///
/// [`read`]: Read::read
/// [`consume`]: BufRead::consume
///
/// This is a lower-level method and is meant to be used together with [`consume`],
/// which can be used to mark bytes that should not be returned by subsequent calls to `read`.
/// which marks bytes as consumed so they will not be returned by subsequent calls to [`read`].
///
/// [`consume`]: BufRead::consume
///
Expand Down
Loading