Package Layout

Cargo uses conventions for file placement to make it easy to dive into a newCargo package:

1. .
2. ├── Cargo.lock
3. ├── Cargo.toml
4. ├── benches
5. │   └── large-input.rs
6. ├── examples
7. │   └── simple.rs
8. ├── src
9. │   ├── bin
10. │   │   └── another_executable.rs
11. │   ├── lib.rs
12. │   └── main.rs
13. └── tests
14. └── some-integration-tests.rs
  • Cargo.toml and Cargo.lock are stored in the root of your package (packageroot).
  • Source code goes in the src directory.
  • The default library file is src/lib.rs.
  • The default executable file is src/main.rs.
  • Other executables can be placed in src/bin/*.rs.
  • Integration tests go in the tests directory (unit tests go in each filethey're testing).
  • Examples go in the examples directory.
  • Benchmarks go in the benches directory.These are explained in more detail in the manifestdescription.