Skip to content

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

Closed
@killercup

Description

@killercup

@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!.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions