Rollup merge of #145356 - GuillaumeGomez:doctest-escaped, r=fmease
Add another example for escaped `#` character in doctest in rustdoc book Fixes rust-lang/rust#118027. We don't plan to add a way to not escape the first `#`, so at least we add a more complete example in the rustdoc book with a macro making use of that.
This commit is contained in:
commit
bb46a20df4
1 changed files with 14 additions and 0 deletions
|
|
@ -191,6 +191,20 @@ We can document it by escaping the initial `#`:
|
|||
/// ## bar # baz";
|
||||
```
|
||||
|
||||
Here is an example with a macro rule which matches on tokens starting with `#`:
|
||||
|
||||
`````rust,no_run
|
||||
/// ```
|
||||
/// macro_rules! ignore { (##tag) => {}; }
|
||||
/// ignore! {
|
||||
/// ###tag
|
||||
/// }
|
||||
/// ```
|
||||
# fn f() {}
|
||||
`````
|
||||
|
||||
As you can see, the rule is expecting two `#`, so when calling it, we need to add an extra `#`
|
||||
because the first one is used as escape.
|
||||
|
||||
## Using `?` in doc tests
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue