Skip to content

Mention try macro in error chapter #22458

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 1 commit into from
Feb 25, 2015

Conversation

steveklabnik
Copy link
Member

Fixes #22342

@rust-highfive
Copy link
Contributor

r? @pcwalton

(rust_highfive has picked a reviewer for you, use r? to override)

fn write_info(info: &Info) -> Result<(), IoError> {
let mut file = File::open_mode(&Path::new("my_best_friends.txt"), Open, Write);
// Early return on error
if let Err(e) = file.write_line(format!("name: {}", info.name).as_slice()) {
Copy link
Member

Choose a reason for hiding this comment

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

I think the more idiomatic usage today would be file.write_line(&format!(...))

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@alexcrichton
Copy link
Member

It may be worth also mentioning the FromError behavior (or at least that it exists). I'm fine referring to other documentation about that part of the try! macro.

@steveklabnik
Copy link
Member Author

@alexcrichton , I took care of everything but the FromError stuff. Where do you think we should link? I'm not sure what docs we even have on this at the moment.

@alexcrichton
Copy link
Member

The FromError documentation may be good enough for now.

rating: i32,
}

fn write_info(info: &Info) -> std::io::Result<()> {
Copy link
Member

Choose a reason for hiding this comment

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

Could this import std::io instead of referencing std::io::Result? (I think the former is more common)

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@steveklabnik
Copy link
Member Author

@alexcrichton updated!

@alexcrichton
Copy link
Member

@bors: r+ f31ea22

@bors
Copy link
Collaborator

bors commented Feb 24, 2015

⌛ Testing commit f31ea22 with merge 8fd791e...

@bors
Copy link
Collaborator

bors commented Feb 24, 2015

⌛ Testing commit f31ea22 with merge fcb6467...

@bors
Copy link
Collaborator

bors commented Feb 24, 2015

💔 Test failed - auto-win-32-opt

@Manishearth
Copy link
Member

(Manually canceled since this will go into a rollup)

@steveklabnik
Copy link
Member Author

Ahh

@Manishearth
Copy link
Member

@bors: retry rollup

Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 24, 2015
@bors bors merged commit f31ea22 into rust-lang:master Feb 25, 2015
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.

Error handling chapter should mention the try! macro
6 participants