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

futures-util/io examples #1108

Merged
merged 2 commits into from
Jul 21, 2018

Conversation

Nemo157
Copy link
Member

@Nemo157 Nemo157 commented Jul 21, 2018

Also fixes WriteAll, it was broken in the same way as ReadExact in #1083

/// let bytes = await!(reader.read(&mut output[..]))?;
///
/// // This is only guaranteed to be 4 because `&[u8]` is a synchronous
/// // reader, in a real system you could get anywhere from 1 to
Copy link
Contributor

Choose a reason for hiding this comment

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

...reader. In a real system

There should be a period because it's a new sentence

/// # Ok::<(), Box<std::error::Error>>(()) }).unwrap();
/// ```
///
/// ## EOF is hit before `buf` is filled
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe write it as "End of file". Some people might not know the term

Copy link
Member Author

Choose a reason for hiding this comment

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

I expanded the earlier "EOF" in this doc-comment to "end of file (EOF)" and left it as shorthand in this heading.

/// {
/// let mut writer = Cursor::new(&mut output[..]);
/// // Note that for `Cursor` the read and write halves share a single
/// // seek position, this may or may not be true for other types that
Copy link
Contributor

Choose a reason for hiding this comment

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

position. This...

/// use std::io::Cursor;
///
/// let mut reader = Cursor::new([1, 2, 3, 4]);
/// let mut buffer = [0, 0, 0, 0, 4, 3, 2, 1];
Copy link
Contributor

Choose a reason for hiding this comment

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

One final tiny thing: Here I'd prefer to not reuse the numbers and instead use different numbers like 5, 6, 7, 8. This makes it more clear what's happening

@MajorBreakfast
Copy link
Contributor

Rebase (again) 🙂

@Nemo157
Copy link
Member Author

Nemo157 commented Jul 21, 2018

Rebased and changed the numbers.

@MajorBreakfast MajorBreakfast merged commit 6dea985 into rust-lang:master Jul 21, 2018
@Nemo157 Nemo157 deleted the futures-util-io-examples branch July 21, 2018 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants