Skip to content

Commit 06b1975

Browse files
committed
Add documentation about the edition flag
1 parent b01e0e4 commit 06b1975

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/doc/rustdoc/src/documentation-tests.md

+16
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,22 @@ compiles, then the test will fail. However please note that code failing
323323
with the current Rust release may work in a future release, as new features
324324
are added.
325325

326+
```text
327+
/// Only runs on the 2018 edition.
328+
///
329+
/// ```edition2018
330+
/// let result: Result<i32, ParseIntError> = try {
331+
/// "1".parse::<i32>()?
332+
/// + "2".parse::<i32>()?
333+
/// + "3".parse::<i32>()?
334+
/// };
335+
/// ```
336+
```
337+
338+
`edition2018` tells `rustdoc` that the code sample should be compiled the 2018
339+
edition of Rust. Similarly, you can specify `edition2015` to compile the code
340+
with the 2015 edition.
341+
326342
## Syntax reference
327343

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

0 commit comments

Comments
 (0)