Skip to content

Commit

Permalink
Add documentation about the edition flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Munksgaard committed Sep 20, 2018
1 parent b01e0e4 commit 06b1975
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/doc/rustdoc/src/documentation-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,22 @@ compiles, then the test will fail. However please note that code failing
with the current Rust release may work in a future release, as new features
are added.

```text
/// Only runs on the 2018 edition.
///
/// ```edition2018
/// let result: Result<i32, ParseIntError> = try {
/// "1".parse::<i32>()?
/// + "2".parse::<i32>()?
/// + "3".parse::<i32>()?
/// };
/// ```
```

`edition2018` tells `rustdoc` that the code sample should be compiled the 2018
edition of Rust. Similarly, you can specify `edition2015` to compile the code
with the 2015 edition.

## Syntax reference

The *exact* syntax for code blocks, including the edge cases, can be found
Expand Down

0 comments on commit 06b1975

Please sign in to comment.