A Rust workspace template repository for multi-crate projects.
This is a workspace-based Rust project template. It provides a clean starting point for Rust applications organized as a Cargo workspace with multiple crates:
- Workspace structure with multiple crates
- Pre-configured CI/CD workflows
- Docker support
- Code formatting and linting setup
- Testing framework (nextest)
- License header checking (hawkeye)
Note: This template is designed for workspace projects with multiple crates. If you need a single-package template for simple applications, please use simple-rust-template instead.
- Rust (stable toolchain)
- just - A command runner (optional but recommended)
- hawkeye - License header checker (required for
just fmtandjust lint) - cargo-nextest - Fast test runner (required for
just test) - cloc - Lines of code counter (required for
just cloc, optional)
-
Clone this repository:
git clone https://github.com/your-username/rust-template.git cd rust-template -
Update
Cargo.tomlwith your workspace configuration and crate details -
Start coding in
crates/cmd/src/main.rsor add new crates to the workspace
# Debug build
cargo build
# Release build
cargo build --releasecargo run -p cmdThis project uses just for common tasks:
# List all available commands
just --list
# Format code
just fmt
# Lint code
just lint
# or use alias
just l
# Run tests
just test
# or use alias
just t
# Calculate lines of code
just clocIf you prefer not to use just:
# Format code
cargo fmt --all
hawkeye format
# Lint code
hawkeye check
cargo check --locked --all --all-features --all-targets
cargo clippy --locked --all-targets --workspace -- -D warnings
# Run tests
cargo nextest run --locked --workspace.
├── crates/
│ └── cmd/ # Example command crate
│ ├── src/
│ │ └── main.rs # Main application entry point
│ └── Cargo.toml # Crate dependencies and metadata
├── deploy/
│ ├── Dockerfile # Docker build configuration
│ └── .dockerignore # Docker ignore patterns
├── .github/
│ └── workflows/ # CI/CD workflows
├── Cargo.toml # Workspace configuration
├── Cargo.lock # Dependency lock file
├── justfile # Just command definitions
├── rust-toolchain.toml # Rust toolchain version
├── rustfmt.toml # Rustfmt configuration
├── clippy.toml # Clippy linting configuration
└── LICENSE # Apache 2.0 License
Build and run with Docker:
cd deploy
docker build -t rust-template .
docker run rust-template- Rust Edition: 2024
- License: Apache-2.0
- Rust Toolchain: Defined in
rust-toolchain.toml - Code Style: Configured in
rustfmt.tomlandclippy.toml - Workspace Resolver: Version 3
Licensed under the Apache License, Version 2.0. See LICENSE for details.
- Single-Package Template: simple-rust-template - For single-package applications