Skip to content

Commit 8a90032

Browse files
authored
Merge pull request #1547 from waldyrious/patch-1
doc_testing.md: clarify tests vs doc-tests
2 parents 911c306 + 1b08684 commit 8a90032

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/testing/doc_testing.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The primary way of documenting a Rust project is through annotating the source
44
code. Documentation comments are written in [markdown] and support code
55
blocks in them. Rust takes care about correctness, so these code blocks are
6-
compiled and used as tests.
6+
compiled and used as documentation tests.
77

88
```rust,ignore
99
/// First line is a short summary describing function.
@@ -48,7 +48,8 @@ pub fn div(a: i32, b: i32) -> i32 {
4848
}
4949
```
5050

51-
Tests can be run with `cargo test`:
51+
Code blocks in documentation are automatically tested
52+
when running the regular `cargo test` command:
5253

5354
```shell
5455
$ cargo test
@@ -73,8 +74,8 @@ the functionality, which is one of the most important
7374
[guidelines][question-instead-of-unwrap]. It allows using examples from docs as
7475
complete code snippets. But using `?` makes compilation fail since `main`
7576
returns `unit`. The ability to hide some source lines from documentation comes
76-
to the rescue: one may write `fn try_main() -> Result<(), ErrorType>`, hide it and
77-
`unwrap` it in hidden `main`. Sounds complicated? Here's an example:
77+
to the rescue: one may write `fn try_main() -> Result<(), ErrorType>`, hide it
78+
and `unwrap` it in hidden `main`. Sounds complicated? Here's an example:
7879

7980
```rust,ignore
8081
/// Using hidden `try_main` in doc tests.

0 commit comments

Comments
 (0)