@@ -38,17 +38,19 @@ function! Forcing you to write `main` for every example, no matter how small,
38
38
adds friction. So ` rustdoc ` processes your examples slightly before
39
39
running them. Here's the full algorithm rustdoc uses to preprocess examples:
40
40
41
- 1 . Any leading ` #![foo] ` attributes are left intact as crate attributes.
42
- 2 . Some common ` allow ` attributes are inserted, including
41
+ 1 . Some common ` allow ` attributes are inserted, including
43
42
` unused_variables ` , ` unused_assignments ` , ` unused_mut ` ,
44
43
` unused_attributes ` , and ` dead_code ` . Small examples often trigger
45
44
these lints.
46
- 3 . If the example does not contain ` extern crate ` , then `extern crate
45
+ 2 . Any attributes specified with ` #![doc(test(attr(...)))] ` are added.
46
+ 3 . Any leading ` #![foo] ` attributes are left intact as crate attributes.
47
+ 4 . If the example does not contain ` extern crate ` , and
48
+ ` #![doc(test(no_crate_inject))] ` was not specified, then `extern crate
47
49
<mycrate >;` is inserted (note the lack of ` #[ macro_use] `).
48
- 4 . Finally, if the example does not contain ` fn main ` , the remainder of the
50
+ 5 . Finally, if the example does not contain ` fn main ` , the remainder of the
49
51
text is wrapped in ` fn main() { your_code } ` .
50
52
51
- For more about that caveat in rule 3 , see "Documeting Macros" below.
53
+ For more about that caveat in rule 4 , see "Documeting Macros" below.
52
54
53
55
## Hiding portions of the example
54
56
@@ -261,4 +263,4 @@ are added.
261
263
The ` no_run ` attribute will compile your code, but not run it. This is
262
264
important for examples such as "Here's how to retrieve a web page,"
263
265
which you would want to ensure compiles, but might be run in a test
264
- environment that has no network access.
266
+ environment that has no network access.
0 commit comments