| name | cargo |
| description | Rust development: build, test, clippy, publish |
Cargo (Rust)
Use the bash tool for Rust development with Cargo.
Setup
-
Check if installed:
command -v cargo && cargo --version
-
Install (rustup provides cargo):
brew install rustup-init && rustup-init
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
Build & Run
cargo build
cargo build --release
cargo run
cargo run --release
Test
cargo test
cargo test -- --nocapture
cargo test test_name
cargo test --doc
cargo bench
Lint & Format
cargo clippy -- -W clippy::pedantic
cargo fmt
cargo fmt -- --check
Dependencies
cargo add <crate>
cargo update
cargo tree
cargo audit
Publish
cargo publish --dry-run
cargo publish
Tips
- Use cargo clippy before committing
- Use cargo audit for security vulnerabilities
- Use cargo tree to visualize dependency graph