Closed
Description
Currently, there is no indication in the documentation for rustdoc that it wraps code blocks in fn main() { ... }
, nor how to stop it from doing so.
To give an example of how this can be very confusing, if you try to test the following code block, you get an error stating "unresolved import f1
. There is no f1
in ???
" which is (seemingly) not true.
pub fn f1() {}
mod a {
use f1;
fn f2() { f1() }
}
Preferably, the docs should note that, by default, all code blocks are wrapped in a main function, that this can be avoided by ensuring the string "fn main" appears (or whatever the actual test is; I think it just looks for a string in the input), and that #
can be used to hide this from the rendered output (which is already in the docs in a different context).