rust-lang / rust-lang/rust

unclear how BufRead::consume interacts with fill_buf

Open
#128,144 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Location

BufRead::consume

Summary

It is not clear if consume should mutate the stream to make fill_buf return less bytes, or if fill_buf can return identical contents after the buffer is partially consumed.

The implementation of BufRead on &[u8] modifies what is returned by fill_buf, so it is at the very least allowed.

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.

This could be interpreted as requiring this behavior, but it could also be interpreted as talking about the behavior of read, since that is the subject of that paragraph. Additionally, this is part of the fill_buf documentation, and it would be somewhat odd to describe what consume must do in the documentation of a different method.

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 at the BufRead::consume and fill_buf documentation linked in the issue, reading the surrounding guidance about returned bytes and read. Clarify whether consume must change subsequent fill_buf results or only account for bytes already consumed, so the documentation gives an unambiguous contract.

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.