Keep examples readable while still compiling.

Section: Docs and doctests

Hide setup lines in doctests

rust
rust
/// ```
/// # use std::path::Path;
/// let path = Path::new("Cargo.toml");
/// assert!(path.exists());
/// ```
Explanation

Hidden `#` lines are a common technique for making doctests compile without cluttering the displayed example.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Docs and doctests
Run doctests only
Focus on failures in documentation examples.
OpenIn sheetbashsame section
Build documentation
Generate local docs for the package and dependencies.
OpenIn sheetbashsame section
Build and open local docs
Generate documentation and launch it in a browser.
OpenIn sheetbashsame section
Clean stale docs and artifacts
Remove target output before a fresh doc build.
OpenIn sheetbashsame section
Run all tests
Build and run the full test suite.
Run a subset of tests
Filter tests by name substring.