about summary refs log tree commit diff
path: root/src/doc/rustdoc
diff options
context:
space:
mode:
authorAndre Bogus <bogusandre@gmail.com>2019-05-28 19:10:39 +0200
committerAndre Bogus <bogusandre@gmail.com>2019-05-28 19:10:39 +0200
commit6bb6c001be34d0932a014df981ee18f165c43374 (patch)
tree566572ce7fe6ba14e58e5121c6c4ad5e0e36ef1a /src/doc/rustdoc
parent7da118581c9dc839c8bf3fbb622bab9ce32bbf38 (diff)
implicit `Option`-returning doctests
This distinguishes `Option` and `Result`-returning doctests with
implicit `main` method, where the former tests must end with
`Some(())`.
Diffstat (limited to 'src/doc/rustdoc')
-rw-r--r--src/doc/rustdoc/src/documentation-tests.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/doc/rustdoc/src/documentation-tests.md b/src/doc/rustdoc/src/documentation-tests.md
index c9acd3c307b..a896ce819ae 100644
--- a/src/doc/rustdoc/src/documentation-tests.md
+++ b/src/doc/rustdoc/src/documentation-tests.md
@@ -253,6 +253,19 @@ conversion, so type inference fails because the type is not unique. Please note
 that you must write the `(())` in one sequence without intermediate whitespace
 so that rustdoc understands you want an implicit `Result`-returning function.
 
+As of version 1.37.0, this simplification also works with `Option`s, which can
+be handy to test e.g. iterators or checked arithmetic, for example:
+
+```ignore
+/// ```
+/// let _ = &[].iter().next()?;
+///# Some(())
+/// ```
+```
+
+Note that the result must be a `Some(())` and this has to be written in one go.
+In this case disambiguating the result isn't required.
+
 ## Documenting macros
 
 Here’s an example of documenting a macro: