A minimal Rust project used to demonstrate development workflow and tooling tips.
- Inner development loop
- Faster linking
- Tooling to speed the loop (cargo-watch)
- Continuous integration (CI)
- Tests
- Code coverage
- Linting
- Formatting
- Security checks
- Ready-to-go CI pipelines
Typical cycle when developing:
- Make a change
- Compile or check the code
- Run tests
- Run the application
Speeding up this loop increases iteration velocity and developer productivity.
Linking can dominate incremental rebuild time. Using LLVM's lld (or other fast linkers) often reduces that time.
Example .cargo/config.toml to prefer lld:
# .cargo/config.toml
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
[target.x86_64-pc-windows-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"]
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld"]Notes on alternatives:
- On Linux try
moldas an alternative linker (fast, younger project). - On macOS there are equivalents (e.g.,
sold), but verify stability for your toolchain.
Windows (MSVC)
# Install helper tools
cargo install -f cargo-binutils
rustup component add llvm-tools-previewLinux
# Ubuntu
sudo apt-get install lld clang
# Arch
sudo pacman -S lld clangmacOS
brew install llvm
# Follow `brew info llvm` for PATH/ld64.lld location on Apple SiliconAfter installing, run incremental builds to measure improvements.
cargo-watch runs commands automatically when files change, reducing perceived wait time.
Install:
cargo install cargo-watchExamples:
# Run `cargo check` on every change
cargo watch -x check
# Chain commands (check → test → run)
cargo watch -x "check" -x "test" -x "run"When you edit in your IDE, cargo-watch can already be compiling in the background.
A healthy CI pipeline ensures the main branch is deployable at any time. Typical automated checks:
Run unit and integration tests:
cargo testCI often runs cargo build or uses incremental caching before tests to speed execution.
Use cargo-llvm-cov to compute LLVM-based coverage.
Install:
rustup component add llvm-tools-preview
cargo install cargo-llvm-covRun:
cargo llvm-covcargo-llvm-cov supports uploading coverage to services like Codecov.
Use Clippy for static analysis.
Install (if missing):
rustup component add clippyRun and treat warnings as errors in CI:
cargo clippy -- -D warningsMute specific lints in code with #[allow(clippy::lint_name)] or configure clippy.toml.
Auto-format with rustfmt to avoid formatting nitpicks in PR reviews.
Install (if missing):
rustup component add rustfmtFormat locally:
cargo fmtCI check:
cargo fmt -- --checkScan dependencies for known vulnerabilities with cargo-audit.
Install:
cargo install cargo-auditRun:
cargo auditConsider running these checks on every commit and on a daily schedule for projects in production.
Other tools: cargo-deny provides more advanced dependency policies (license checks, duplicates, unmaintained crates).
Use prepared CI templates (for GitHub Actions, GitLab CI, etc.) that run the steps above. Start from a template and adapt provider-specific configuration to your project.
- Add a
.cargo/config.tomlif you plan to switch linkers. - Add CI workflow files in
.github/workflows/to enforce checks on pushes and PRs. - Consider editor integrations: format-on-save and Clippy runs to keep the inner loop fast.
// ...existing code... { changed code } // ...existing code...