Skip to content

Update rustdoc book to suggest using Termination trait instead of hidden ‘foo’ function #50721

Closed
@frewsxcv

Description

@frewsxcv

Towards the end of this section in the rustdoc book, we suggest wrapping functions that utilize ? with fn foo() -> io::Result<()> { .. }.

Now that the Termination trait has stabilized, we can recommend using that instead of this hidden foo function. For examples of what I mean, see this pull request.


@steveklabnik is happy to mentor anyone who wants to do this. Here's the basic outline of what needs to happen:

Here's the file that needs to be modified: https://github.com/rust-lang/rust/blob/master/src/doc/rustdoc/src/documentation-tests.md

The part that starts with:

Another case where the use of # is handy is when you want to ignore error handling. Lets say you want the following,

This should be moved into its own section, "Using ? in doc tests", and instead of wrapping it in a function, it should suggest something similar to the diff above.

If you have any questions about this, don't hesitate to ask in a comment below!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-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.P-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions