]> git.lizzy.rs Git - rust.git/commitdiff
Add documentation about the edition flag
authorPhilip Munksgaard <pmunksgaard@gmail.com>
Wed, 19 Sep 2018 14:35:25 +0000 (16:35 +0200)
committerPhilip Munksgaard <pmunksgaard@gmail.com>
Thu, 20 Sep 2018 06:36:07 +0000 (08:36 +0200)
src/doc/rustdoc/src/documentation-tests.md

index e4af122d0cb98d55938994581144f0803faa0f33..dd8dcb7ff9bd23e886b3071c60b69af31cf3e17f 100644 (file)
@@ -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