Rust Development
Testing
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Run specific test
cargo test test_name
# Run ignored tests
cargo test -- --ignored
Linting
# Run clippy
cargo clippy -- -D warnings
# Check without building
cargo check
Formatting
# Format code
cargo fmt
# Check format without changing
cargo fmt --check
Project Structure
project/
āāā src/
ā āāā lib.rs
ā āāā main.rs
āāā tests/
ā āāā integration_test.rs
āāā Cargo.toml
āāā README.md
Cargo.toml Template
[package]
name = "project-name"
version = "0.1.0"
edition = "2021"
[dependencies]
[dev-dependencies]
[lints.rust]
unsafe_code = "forbid"
[lints.clippy]
all = "warn"
pedantic = "warn"
TDD Cycle Commands
# RED: Write test, run to see it fail
cargo test test_new_feature
# GREEN: Implement, run to see it pass
cargo test test_new_feature
# REFACTOR: Clean up, ensure tests still pass
cargo test && cargo clippy && cargo fmt --check