| name | cargo-ecosystem |
| description | Master Cargo, testing, and Rust development tools. Use when configuring Cargo.toml, setting up workspaces, build profiles, or development tooling. |
Cargo & Ecosystem Skill
Master Rust's build system, package manager, and development tools.
Quick Start
Essential Commands
cargo new my_project
cargo new my_lib --lib
cargo init
cargo build
cargo build --release
cargo run
cargo run --release
cargo test
cargo test test_name
cargo test -- --nocapture
cargo fmt
cargo clippy
cargo doc --open
Cargo.toml Configuration
[package]
name = "my-app"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"
authors = ["You <you@example.com>"]
description = "A sample application"
license = "MIT"
repository = "https://github.com/you/my-app"
[dependencies]
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
proptest = "1.0"
[profile.release]
lto = true
codegen-units = 1
opt-level = 3
[[bin]]
name = "my-app"
path = "src/main.rs"
[[bench]]
name = "my_benchmark"
harness = false
Testing
Unit Tests
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add() {
assert_eq!(add(2, 2), 4);
}
#[test]
#[should_panic(expected = "overflow")]
fn test_panic() {
}
#[test]
#[ignore]
fn slow_test() {
}
}
Integration Tests
use my_crate::public_function;
#[test]
fn test_public_api() {
assert!(public_function().is_ok());
}
Benchmarks
use criterion::{criterion_group, criterion_main, Criterion};
fn benchmark(c: &mut Criterion) {
c.bench_function("my_function", |b| {
b.iter(|| my_function())
});
}
criterion_group!(benches, benchmark);
criterion_main!(benches);
Development Tools
Code Quality
rustup component add rustfmt clippy
cargo fmt
cargo fmt -- --check
cargo clippy
cargo clippy -- -D warnings
cargo clippy --fix
Recommended Tools
cargo install cargo-watch
cargo install cargo-edit
cargo install cargo-nextest
cargo install cargo-audit
cargo install cargo-bloat
rustfmt.toml
edition = "2021"
max_width = 100
use_small_heuristics = "Max"
tab_spaces = 4
.cargo/config.toml
[alias]
t = "test"
c = "clippy"
b = "build --release"
[build]
rustflags = ["-D", "warnings"]
Workspaces
[workspace]
members = [
"core",
"cli",
"server",
]
[workspace.dependencies]
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
Resources