Improve several Read
implementations by a1phyr · Pull Request #122441 · rust-lang/rust (original) (raw)
Perhaps
self.limit
should be set to 0 ifErr(EOF)
is returned fromTake::read_(buf_)exact
? Though this would "decouple" the limit from how many bytes are actually read, but that already happens if we do call into the inner reader and itsread_exact
fails, so 🤷.
I think that Take
should never read more that limit
bytes, whatever the circumstances, and decoupling seems wrong to me too. Only the default implementation feels correct, so I have removed Take::read_(buf_)exact
from the PR.
One thing though, &[u8]
and Cursor
have this problem, so this should probably be changed in a follow-up PR.