Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Build the Project

Prerequisite: Regardless of whether you are using VS Code with Dev Containers or running docker run manually, from this section onward we assume that you are working inside a terminal session running in the Docker container we previously setup in Development Environment Setup.

To manage projects of arbitrary size, this repository is organized as a Cargo workspace. A workspace makes it easier to develop and maintain multiple related crates within a single project. This approach allows multiple binaries, libraries, examples, and experiments to coexist in a single repository while sharing dependencies and build configuration.

In this repository, the rust_playground/rs-ws directory acts as the workspace root and contains all the crates that we will develop throughout this book.

Build

To check all crates in the workspace, run:

cargo check --workspace --all-targets

Or, to directly build all crates in the workspace, run:

cargo build --workspace --all-targets

cargo check checks a local package and all of its dependencies for errors. This will essentially compile the packages without performing the final step of code generation, which is faster than running cargo build.

References:

Format

To format all crates in the workspace, run:

cargo fmt --verbose --all

References:

Run lints (Clippy)

Clippy is a collection of lints to catch common mistakes and improve our Rust code. It is a superset of the default rustc lints.

cargo clippy --verbose --all-targets --release

References:

Run tests

To execute all unit tests and integration tests across the workspace, run:

cargo test --workspace --all-targets

References:

Line coverage report

To generate a code coverage report, run:

cargo llvm-cov --workspace --lib --all-features

References:

Generate the docs

Rust can automatically generate documentation from comments written in the source code.

To generate the documentation for the entire workspace, run:

cargo doc --workspace --no-deps

References: