Where should one put the sources, examples, documentation, unit tests, integration tests, license, benchmarks etc?
相关问题
- Share Arc between closures
- Function references: expected bound lifetime param
- Pattern matching on slices
- How can I iteratively call Sha256::digest, passing
- Destructure a vector into variables and give away
相关文章
- How can I convert a f64 to f32 and get the closest
- What is a good way of cleaning up after a unit tes
- How can I unpack (destructure) elements from a vec
- How to import macros in Rust?
- How to get struct field names in Rust? [duplicate]
- Confusion between [T] and &[T]
- How do I initialize an opaque C struct when using
- What's the most idiomatic way to test two Opti
Cargo, the official package manager for Rust, defines some conventions regarding the layout of a Rust crate:
By following this standard layout, you'll be able to use Cargo's commands to build, run and test your project easily. Run
cargo new
to set up a new executable project orcargo new --lib
to set up a new library project.Additionally, documentation for libraries is often written in documentation comments (comments that start with
///
before any item, or//!
to document the parent item). Also, the license is usually put at the root.Unit tests, as mentioned above, are written in the same module as the functions they're testing. Usually, they're put in an inner module. It looks like this (this is what Cargo generates for a new library with
cargo new --lib
):