-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Documentation for io::Read::read's return value #70360
Copy link
Copy link
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
As far as I know
Fileuseslibc::readon unix for itsReadimplementation. Thereadmethod returns the amount of bytes that were read to the given buffer.libc::read's man page says the following:It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal), or because read() was interrupted by a signal.I think the documentation for
io::Readdoesn't currently make it clear that the returned value can be less than the buffer size, even when the reader is not at the end of the stream. While this behaviour may seem obvious to anyone familiar with libc, it should still be documented, as it's not obvious for those coming from other languages, and it can be important in some cases.