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
Changes from chapter 13 2nd page review #1233
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
carols10cents
commented
Mar 19, 2018
|
||
We can call the `next` method on iterators directly; Listing 13-15 demonstrates | ||
what values are returned from repeated calls to `next` on the iterator created | ||
from the vector: | ||
|
||
<span class="filename">Filename: src/lib.rs</span> | ||
|
||
```rust,test_harness | ||
```rust |
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.
this change has nothing to do with page review, i just noticed it and remembered that it isn't a thing anymore rust-lang/rust#42288 (comment)
carols10cents
added a commit
that referenced
this pull request
Dec 9, 2020
The reasons we needed empty `fn main() {}`s were twofold: - Avoid confusing people when they click the "expand" button on the code listing and see the auto-main wrapping - Avoid failing doctests when running `mdbook test` that don't work when rustdoc wraps a code listing in main I think I have a solution that mostly solves these cases. I don't know why this didn't occur to me before. Here's my current thinking in case these assumptions turn out to be wrong: There are a [few things that tell mdbook to disable the main-wrapping][mdbook], and I hadn't noticed one of them until now: if you annotate a code block with `noplayground`, it won't add a `main` around it (and it also won't have the "play" button in the upper right that runs the block and inserts the result into the page). So instead of putting an empty `fn main() {}` at the bottom of src/lib.rs files that doesn't make sense, annotate those listings with `noplayground`. I don't think anyone will miss the play button anyway because: - The play button doesn't run tests, so there wasn't any output for these examples anyway - If an example doesn't compile, we have it marked `ignore` so that it doesn't make the tests fail, and `ignore` also disables the play button, so there isn't a way to see compiler errors either In most of these cases, `mdbook test` that runs these as doctests will still wrap these in main, but the tests still pass. There are some cases, mostly around modules and using `crate::` that won't pass as doctests when wrapped in main. For those, I've annotated them with the [undocumented][] [`test_harness`][] attribute that apparently I was using at some point and then [stopped using][] and now I've decided to use again, but maybe send in a PR to rust-lang/rust to change the name to `no_main` and document it or something. In any case, that shouldn't affect readers at all. [mdbook]: https://github.com/rust-lang/mdBook/blob/d0deee90b04068ed949f524bb682a47fa26f2218/src/renderer/html_handlebars/hbs_renderer.rs#L805-L808 [undocumented]: rust-lang/rust#42288 (comment) [`test_harness`]: https://github.com/rust-lang/rust/blob/220352781c2585f0efb07ab0e758b136514de5b8/src/librustdoc/doctest.rs#L252 [stopped using]: #1233 (comment)
carols10cents
added a commit
that referenced
this pull request
Dec 9, 2020
The reasons we needed empty `fn main() {}`s were twofold: - Avoid confusing people when they click the "expand" button on the code listing and see the auto-main wrapping - Avoid failing doctests when running `mdbook test` that don't work when rustdoc wraps a code listing in main I think I have a solution that mostly solves these cases. I don't know why this didn't occur to me before. Here's my current thinking in case these assumptions turn out to be wrong: There are a [few things that tell mdbook to disable the main-wrapping][mdbook], and I hadn't noticed one of them until now: if you annotate a code block with `noplayground`, it won't add a `main` around it (and it also won't have the "play" button in the upper right that runs the block and inserts the result into the page). So instead of putting an empty `fn main() {}` at the bottom of src/lib.rs files that doesn't make sense, annotate those listings with `noplayground`. I don't think anyone will miss the play button anyway because: - The play button doesn't run tests, so there wasn't any output for these examples anyway - If an example doesn't compile, we have it marked `ignore` so that it doesn't make the tests fail, and `ignore` also disables the play button, so there isn't a way to see compiler errors either In most of these cases, `mdbook test` that runs these as doctests will still wrap these in main, but the tests still pass. There are some cases, mostly around modules and using `crate::` that won't pass as doctests when wrapped in main. For those, I've annotated them with the [undocumented][] [`test_harness`][] attribute that apparently I was using at some point and then [stopped using][] and now I've decided to use again, but maybe send in a PR to rust-lang/rust to change the name to `no_main` and document it or something. In any case, that shouldn't affect readers at all. [mdbook]: https://github.com/rust-lang/mdBook/blob/d0deee90b04068ed949f524bb682a47fa26f2218/src/renderer/html_handlebars/hbs_renderer.rs#L805-L808 [undocumented]: rust-lang/rust#42288 (comment) [`test_harness`]: https://github.com/rust-lang/rust/blob/220352781c2585f0efb07ab0e758b136514de5b8/src/librustdoc/doctest.rs#L252 [stopped using]: #1233 (comment)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
wheeee