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

Docs: unchecked file.write() in example #51621

Closed
yongqli opened this issue Jun 18, 2018 · 0 comments
Closed

Docs: unchecked file.write() in example #51621

yongqli opened this issue Jun 18, 2018 · 0 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools

Comments

@yongqli
Copy link

yongqli commented Jun 18, 2018

In the example for LineWriter there is this code fragment:

    for &byte in road_not_taken.iter() {
       file.write(&[byte]).unwrap();
    }

This code isn't correct -- it should be file.write_all instead. In fact, trying the run the example fails on play.rust-lang.org.

@steveklabnik steveklabnik added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Jun 21, 2018
euclio added a commit to euclio/rust that referenced this issue Jul 8, 2018
The original example didn't check the return value of `write()`, didn't
flush the writer, and didn't properly demonstrate the buffering.

Fixes rust-lang#51621.
kennytm added a commit to kennytm/rust that referenced this issue Jul 18, 2018
use checked write in `LineWriter` example

The example was wrong because it didn't check the return value of
`write()`, and it didn't flush the buffer before comparing the contents
of the file.

Fixes rust-lang#51621.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

No branches or pull requests

2 participants