1
0
Fork
You've already forked rust-bin-template
0
A Rust binary template project with bits and pieces that are annoying to add separately.
  • Rust 95.5%
  • Gherkin 4.5%
2026年07月11日 10:40:55 +02:00
dev-tools Move the Dev Tools 2026年07月05日 18:21:26 +02:00
src Correct Clippy interventions. 2026年07月11日 10:40:55 +02:00
tests Move the Dev Tools 2026年07月05日 18:21:26 +02:00
.gitignore Move the Dev Tools 2026年07月05日 18:21:26 +02:00
Cargo.lock Move the Dev Tools 2026年07月05日 18:21:26 +02:00
Cargo.toml Move the Dev Tools 2026年07月05日 18:21:26 +02:00
coverage-threshold Initial Commit 2026年07月05日 18:21:13 +02:00
LICENSE Reset the license. It should be a choice for the template user. 2026年07月05日 18:21:26 +02:00
prek.toml Add builtins and clippy, also clean before measuring coverage. 2026年07月11日 10:39:32 +02:00
README.md Move the Dev Tools 2026年07月05日 18:21:26 +02:00

Rust Bin Template

A Rust binary template with branch coverage enforcement, mutation testing, and a pre-commit pipeline via prek.


How to Build & Run

Prerequisites

Install Rust, then install coverage and pre-commit tools:

# Install cargo-llvm-cov & nightly toolchain for coverage
rustup toolchain install nightly
rustup component add llvm-tools --toolchain nightly
cargo install cargo-llvm-cov
# Install cargo-mutants for mutation testing
cargo install cargo-mutants
# Install prek
cargo install prek

Building & Running

cargo build # Debug build
cargo build --release # Release build
cargo run # Run the CLI binary

CLI Commands

cargo run -- add "Buy milk"
cargo run -- list
cargo run -- complete 0
cargo run -- delete 0

Testing

Run all unit tests:

cargo test --all-features
  • Unit tests: Located in src/lib.rs and dev-tools/src/bin/cargo-covcheck.rs.

Coverage & Mutation Testing

Branch Coverage

cargo run -p dev-tools --bin cargo-covcheck

Threshold is set in coverage-threshold. Results via cargo +nightly llvm-cov --branch --html.

Mutation Testing

cargo run -p dev-tools --bin cargo-mutcheck

Review mutants.out/missed.txt for surviving mutations; strengthen tests accordingly.


Pre-commit Hooks

Set up hooks in this repository:

prek install

Once set up, these checks run automatically on every commit:

  • cargo fmt --check (auto-formats on failure)
  • cargo test --all-features
  • cargo run -p dev-tools --bin cargo-covcheck

Run manually:

prek run --all-files

Contributing

  1. Format: cargo fmt
  2. Test: cargo test --all-features
  3. Verify Coverage & Mutations:
    • Coverage: cargo run -p dev-tools --bin cargo-covcheck
    • Mutation: cargo run -p dev-tools --bin cargo-mutcheck
  4. Hooks: Ensure prek run --all-files passes.
  5. Open a Pull Request with your changes.

Workspace Structure

  • src/ - Main library and binary
  • dev-tools/ - Helper utilities for coverage and mutation testing