mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-04 09:53:04 +03:00
rustdoc book on codeblock hash escaping
This commit is contained in:
@@ -170,6 +170,23 @@ By repeating all parts of the example, you can ensure that your example still
|
||||
compiles, while only showing the parts that are relevant to that part of your
|
||||
explanation.
|
||||
|
||||
The `#`-hiding of lines can be prevented by using two consecutive hashes
|
||||
`##`. This only needs to be done with with the first `#` which would've
|
||||
otherwise caused hiding. If we have a string literal like the following,
|
||||
which has a line that starts with a `#`:
|
||||
|
||||
```rust
|
||||
let s = "foo
|
||||
## bar # baz";
|
||||
```
|
||||
|
||||
We can document it by escaping the initial `#`:
|
||||
|
||||
```text
|
||||
/// let s = "foo
|
||||
/// ## bar # baz";
|
||||
```
|
||||
|
||||
|
||||
## Using `?` in doc tests
|
||||
|
||||
|
||||
Reference in New Issue
Block a user