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

Different styles between examples that should panic #73196

Closed
JakobDegen opened this issue Jun 10, 2020 · 2 comments · Fixed by #73302
Closed

Different styles between examples that should panic #73196

JakobDegen opened this issue Jun 10, 2020 · 2 comments · Fixed by #73302
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@JakobDegen
Copy link
Contributor

I happened to stumble across this documentation earlier, and was surprised by the style of the following example of code that should panic:

use std::thread;

let result = thread::spawn(|| {
    // this panics
    '1'.is_digit(37);
}).join();

assert!(result.is_err());

In particular, this does not seem to use the should_panic attribute that is used in other places in the documentation (eg Option's unwrap ). As a result, it seems unnecessarily hard to read especially since this is a method which is likely to be of interest even for very new users. I was going to open a PR fixing this, but first wanted to ask if there is any particular reason for or benefit from this style? It also appears in a number of other places in the documentation for char - I have not yet searched elsewhere.

@crlf0710 crlf0710 added C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Jun 11, 2020
@poliorcetics
Copy link
Contributor

@JakobDegen this could be fixed to be shorter and clearer you are right.

Do you want to do it ?

@JakobDegen
Copy link
Contributor Author

@poliorcetics yeah, I'd already written the patch, was just looking for some help with running the doctests (apparently they're partially broken right now). Its all worked out now though, and I'll submit a PR in a couple of minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants