Skip to content

Significantly improve documentation for the traits in std::io #26924

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

Merged
merged 5 commits into from
Jul 17, 2015

Conversation

steveklabnik
Copy link
Member

Examples for everything, as well as some cleanup and consistency changes.

r? @alexcrichton

/// returning how many bytes were successfully written.
/// Implementors of the `Write` trait are sometimes called 'writers'.
///
/// Readers are defined by two required methods, `write()` and `flush()`:

Choose a reason for hiding this comment

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

Writers are defined by

/// let mut buffer = try!(OpenOptions::new().write(true).open("foo.txt"));
///
/// buffer.write(b"some bytes").unwrap();
/// buffer.flush().unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

try! on these operations?

Copy link
Member

Choose a reason for hiding this comment

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

(and the ones in the below examples)

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 had made a mental note that 'now that i've converted these things to files i can try instead of unwrap' and then forgot, thanks :)

@steveklabnik steveklabnik force-pushed the doc_io_traits_enums branch 2 times, most recently from 7f96964 to 0e1b874 Compare July 11, 2015 00:08
@steveklabnik
Copy link
Member Author

updated some more, and feeling good about it :)

/// let mut buffer = String::new();
///
/// while stdin.read_line(&mut buffer).unwrap() > 0 {
/// if n == 0 { break } // eof
Copy link
Member

Choose a reason for hiding this comment

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

This line can be deleted now

@alexcrichton
Copy link
Member

I am as well! Thanks so much @steveklabnik!

r=me with just a few last nits

@alexcrichton
Copy link
Member

(travis also failed)

@steveklabnik steveklabnik force-pushed the doc_io_traits_enums branch from 0e1b874 to 4fb02a3 Compare July 16, 2015 17:38
@steveklabnik
Copy link
Member Author

@bors: r=alexcrichton rollup

@bors
Copy link
Collaborator

bors commented Jul 16, 2015

📌 Commit 4fb02a3 has been approved by alexcrichton

@steveklabnik
Copy link
Member Author

🎊

@bors bors merged commit 4fb02a3 into rust-lang:master Jul 17, 2015
bors added a commit that referenced this pull request Aug 18, 2015
"Don't seek past end of stream" is mentioned twice in a row. This happened because seeking before offset 0 was previously mentioned there, and was moved to the "errors" section afterwards.

Somehow made it through [#26924](https://github.com/rust-lang/rust/pull/26924/files#diff-668f8f358d4a93474b396dcb3727399eR825).
@steveklabnik steveklabnik deleted the doc_io_traits_enums branch June 19, 2016 20:33
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.

5 participants