We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1e1bfc7 commit a48224bCopy full SHA for a48224b
src/doc/rustdoc/src/documentation-tests.md
@@ -31,6 +31,22 @@ let x = 5;
31
32
There's some subtlety though! Read on for more details.
33
34
+## Passing or failing a doctest
35
+
36
+Like regular unit tests, regular doctests are considered to "pass"
37
+if they compile and run without panicking.
38
+So if you want to demonstrate that some computation gives a certain result,
39
+the `assert!` family of macros works the same as other Rust code:
40
41
+```rust
42
+let foo = "foo";
43
44
+assert_eq!(foo, "foo");
45
+```
46
47
+This way, if the computation ever returns something different,
48
+the code panics and the doctest fails.
49
50
## Pre-processing examples
51
52
In the example above, you'll note something strange: there's no `main`
0 commit comments