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

Fix example for BufferedReader #18374

Merged
merged 1 commit into from
Oct 30, 2014
Merged

Fix example for BufferedReader #18374

merged 1 commit into from
Oct 30, 2014

Conversation

steveklabnik
Copy link
Member

Fixes #18197

/// use std::io::{BufferedWriter, File};
///
/// let file = File::open(&Path::new("message.txt"));
/// let file = File::create(&Path::new("message.txt"));
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a .unwrap() here too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Does it need it? This example works as-is.

Copy link
Member

Choose a reason for hiding this comment

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

It works because we have a sketchy (IMO) impl<E> Stream for Result<Stream, E>

@steveklabnik
Copy link
Member Author

@sfackler done

/// let file = File::open(&Path::new("message.txt"));
/// let mut writer = BufferedWriter::new(file);
/// let file = File::create(&Path::new("message.txt"));
/// let mut writer = BufferedWriter::new(file).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Oh, sorry, I was looking for this to end up on the call to File::create, not BufferedWriter::new.

Copy link
Member Author

Choose a reason for hiding this comment

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

whoops! duh.

@steveklabnik
Copy link
Member Author

updated!

bors added a commit that referenced this pull request Oct 30, 2014
@bors bors closed this Oct 30, 2014
@bors bors merged commit 72fb8f3 into rust-lang:master Oct 30, 2014
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.

Doc's example code for BufferedWriter is wrong and also generate warnings
4 participants