Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Clarify EOF condition for AsyncReadExt::read_buf #3850

Merged
merged 3 commits into from Jun 9, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions tokio/src/io/util/async_read_ext.rs
Expand Up @@ -181,8 +181,9 @@ cfg_io_util! {
/// # Return
///
/// On a successful read, the number of read bytes is returned. If the
/// supplied buffer is not empty and the function returns `Ok(0)` then
/// the source has reached an "end-of-file" event.
/// remaining capacity of the supplied buffer is greater than 0 and
/// the function returns `Ok(0)` then the source has reached an
/// "end-of-file" event.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would read even better if we made a list with the two cases like we do on AsyncReadExt::read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I pulled the comment down from read, but changed the second point for read_buf because I think the concept of "remaining capacity" makes more sense for BufMut than length since a BufMut has the concept of initialized length and uninitialized remaining capacity.

Here's the change for that line:

- 2. The buffer specified was 0 bytes in length.
+ 2. The buffer specified had a remaining capacity of zero.

///
/// # Errors
///
Expand Down