-
Notifications
You must be signed in to change notification settings - Fork 632
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
futures-util/io examples #1108
Conversation
futures-util/src/io/mod.rs
Outdated
/// 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
futures-util/src/io/mod.rs
Outdated
/// { | ||
/// 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
position. This...
futures-util/src/io/mod.rs
Outdated
/// use std::io::Cursor; | ||
/// | ||
/// let mut reader = Cursor::new([1, 2, 3, 4]); | ||
/// let mut buffer = [0, 0, 0, 0, 4, 3, 2, 1]; |
There was a problem hiding this comment.
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
Rebase (again) 🙂 |
66a9b3d
to
ea11c8d
Compare
Rebased and changed the numbers. |
Also fixes
WriteAll
, it was broken in the same way asReadExact
in #1083