871 B
871 B
File rules
Avoid generic Rust file names
Rule
Do not name Rust source files lib.rs or main.rs.
Name library crate root files after the crate they define.
Name binary crate root files after the binary they define, or use a _main.rs suffix.
Set explicit Cargo paths and Bazel srcs when needed.
Rationale
Generic root names make file search results and review context less clear. Descriptive file names show which crate or binary owns the code.
Keep Rust tests in separate files
Rule
Put Rust tests in separate *_test.rs files.
Name each test file after the Rust source file or crate root that it tests.
Do not use generic test file names such as lib_test.rs or main_test.rs.
Do not add inline #[cfg(test)] modules.
Rationale
Separate test files keep production modules focused and match the repository's Bazel test layout.