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

Document how to best write examples that use try for error handling #29234

Closed
killercup opened this issue Oct 22, 2015 · 4 comments
Closed

Document how to best write examples that use try for error handling #29234

killercup opened this issue Oct 22, 2015 · 4 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Comments

@killercup
Copy link
Member

@steveklabnik wrote on reddit, this this is a common style in std:

/// A doc test using `try!`:
///
/// ```
/// # fn f() -> io::Result<()> {
/// let x = try!(package.open()); // danger, might explode
/// x.insert("valuables", 42)
/// try!(x.close_and_reactivate());
/// # Ok(())
/// # }
/// # f();
/// ```

We should add that to the documentation chapter of TRPL and maybe also to the docs of try!.

@steveklabnik steveklabnik added A-docs E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Oct 22, 2015
@steveklabnik
Copy link
Member

I'm willing to mentor anyone who wants to do this.

@ghost
Copy link

ghost commented Oct 22, 2015

I'll take this on.

@steveklabnik
Copy link
Member

@EFindlay great! Let me know if you need any help.

@ghost
Copy link

ghost commented Oct 28, 2015

I reduced the example to one try! Maybe its better to have two try! s. I'm not sure.

@bors bors closed this as completed in b2c3745 Nov 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Projects
None yet
Development

No branches or pull requests

2 participants