Clarify BufRead::fill_buf doesn't consume data#150584
Open
Sekar-C-Mca wants to merge 1 commit intorust-lang:mainfrom
Open
Clarify BufRead::fill_buf doesn't consume data#150584Sekar-C-Mca wants to merge 1 commit intorust-lang:mainfrom
Sekar-C-Mca wants to merge 1 commit intorust-lang:mainfrom
Conversation
The previous documentation said 'via Read methods' which incorrectly implied that fill_buf consumes the data. This restores the historical clarification that read() can return the same contents as fill_buf, and emphasizes the relationship with consume(). This addresses the concerns raised in the issue where implementations like BufReader and Cursor do not actually consume data when fill_buf is called - subsequent read() calls can still read the same bytes until consume() is explicitly called.
Collaborator
|
r? @ChrisDenton rustbot has assigned @ChrisDenton. Use |
ChrisDenton
reviewed
Jan 8, 2026
| /// 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 |
Member
There was a problem hiding this comment.
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"...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #149000
The previous documentation said 'via Read methods' which incorrectly implied that fill_buf consumes the data. This restores the historical clarification that read() can return the same contents as fill_buf, and emphasizes the relationship with consume().
This addresses the concerns raised in the issue where implementations like BufReader and Cursor do not actually consume data when fill_buf is called - subsequent read() calls can still read the same bytes until consume() is explicitly called.