Rust development best practices and patterns. USE WHEN writing Rust code, designing Rust projects, working with Cargo, testing, or Rust package development.
Modern Rust development guidance using Cargo, Clippy, and best practices.
This skill provides comprehensive guidance for Rust development following 2025 best practices:
# Create binary
cargo new myapp
# Create library
cargo new --lib mylib
cd myapp
cargo build
cargo run
cargo add serde tokio anyhow
cargo add --dev proptest criterion
# Format code
cargo fmt
# Lint code
cargo clippy --all-targets --all-features -- -D warnings
# Run tests
cargo test
# Run benchmarks
cargo bench
Rust's ownership system ensures memory safety without garbage collection:
fn main() {
let s = String::from("hello"); // s owns the string
takes_ownership(s); // s moved, no longer valid
// println!("{}", s); // Would error!
let x = 5;
makes_copy(x); // i32 is Copy, x still valid
println!("{}", x); // OK!
}
Use Result and Option instead of exceptions:
use anyhow::{Context, Result};
fn process_file(path: &str) -> Result<()> {
let contents = std::fs::read_to_string(path)
.context("Failed to read file")?;
// Process contents...
Ok(())
}
High-level code compiles to efficient machine code:
// Iterator chain - as fast as hand-written loop
let sum: i32 = numbers
.iter()
.filter(|&&x| x % 2 == 0)
.map(|&x| x * 2)
.sum();
unwrap() in libraries/// doc commentsSearch for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer