-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Mention try macro in error chapter #22458
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
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()) { |
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 think the more idiomatic usage today would be file.write_line(&format!(...))
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.
👍
It may be worth also mentioning the |
@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. |
The |
rating: i32, | ||
} | ||
|
||
fn write_info(info: &Info) -> std::io::Result<()> { |
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.
Could this import std::io
instead of referencing std::io::Result
? (I think the former is more common)
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.
👍
61dc770
to
f31ea22
Compare
@alexcrichton updated! |
⌛ Testing commit f31ea22 with merge 8fd791e... |
⌛ Testing commit f31ea22 with merge fcb6467... |
💔 Test failed - auto-win-32-opt |
(Manually canceled since this will go into a rollup) |
Ahh |
@bors: retry rollup |
…r=alexcrichton Fixes rust-lang#22342
Fixes #22342