RS.CLIPPY.NEEDLESS_DOCTEST_MAIN
Presence of `fn main() {` in code examples
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: needless_doctest_main. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for fn main() { .. } in doctests
Why is this bad?
The test can be shorter (and likely more readable)
if the fn main() is left implicit.
Examples
/// An example of a doctest with a `main()` function
///
/// # Examples
///
/// ```
/// fn main() {
/// // this needs not be in an `fn`
/// }
/// ```
fn needless_main() {
unimplemented!();
}