The `dbg!` macro, being deployed more widely in #2478, shows the line
number. But if we inject `#![allow(..)]\n` then the printed numbers do
not match those in the textarea. It turns out that `\n` is not required!
cc @egithinji
The content slides all use `fn main`, with the exception of the testing
segment. But with this change, where it makes sense exercises use tests
instead, and not both tests and `fn main`.
A small change in `book.js` supports running tests when a code sample
does not have `fn main` but does have `#[test]`, so these work
naturally.
Fixes#1581.
These sort of warnings can be distracting when commenting out a few
lines of code or demonstrating some other concept. They can be
re-enabled for a code block with `warnunused`.
I filed https://github.com/rust-lang/mdBook/issues/2527 to get behavior
like this upstream.
It used to have a ugly error message shows that "Playground
Communication: Cannot read properties of undefined (reading 'trim')",
which is due to the fact that the response lacks stdout attr.
Issue: #2477
Signed-off-by: Alx-Lai <alexabc722@gmail.com>
Reverts google/comprehensive-rust#2397
I'm seeing
```
POST https://play.rust-lang.org/execute 500 (Internal Server Error)
```
on every request when trying to run code in the Playground. I'm not sure
why, but we need to revert this ASAP if others see the same.
Add a stderr block.
Pros:
- we can make use of dbg macro in our code Cons:
- there's a limitation that the compile message also shows
Applies patches from rust-lang/mdBook#1315 since the original change was
not merged by rust-lang.
Issue: #531
Signed-off-by: Alx-Lai <alexabc722@gmail.com>
Before we would run `mdbook test` using the current Markdown sources.
This is subtly wrong: we publish the course using back-dated sources,
so we should therefore also run the tests using the same sources (this
ensures that the code snippets actually work).
After this commit, all translatable content lives in exactly two
directories:
- `src/`
- `third_party/`
We need to restore both directories when testing and when publishing.
This ensures consistency in the Markdown text and in the included
source code.
A new `.github/workflows/build.sh` script takes care of preparing the
two directories according to the date in the PO file (if any).
To ensure we can restore all of `third_party/` to an old commit, the
non-changing `third_party/mdbook/book.js` file has been moved to
`theme/book.js`. The file is generated by `mdbook init --theme`,
making it suitable for modification by the user (us). Symlinks have
been added to `third_party/mdbook/` to indicate that the files
ultimately came from upstream.