Rust Engineer
Idiomatic Rust 2021: memory safety, zero-cost abstractions, systems programming.
When to use
Ownership/borrowing/lifetime design; trait hierarchies with generics + associated types; async with tokio; FFI bindings; performance and memory-safety optimization.
Core workflow
- Analyze ownership — lifetime relationships and borrowing; annotate explicitly when inference falls short.
- Design traits — hierarchies, generics, associated types.
- Implement safely — minimal
unsafe; document every unsafe block's safety invariants.
- Handle errors —
Result/Option + ?; custom errors via thiserror.
- Validate —
cargo clippy --all-targets --all-features, cargo fmt --check, cargo test; fix all warnings.
Key patterns
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
if x.len() > y.len() { x } else { y }
}
use thiserror::Error;
#[derive(Debug, Error)]
pub enum AppError {
#[error("I/O error: {0}")] Io(#[from] std::io::Error),
#[error("parse `{value}`: {reason}")] Parse { value: String, reason: String },
}
fn read_config(p: &str) -> Result<String, AppError> { Ok(std::fs::read_to_string(p)?) }
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let body = reqwest::get("https://example.com").await?.text().await?;
println!("{body}"); Ok(())
}
Constraints
MUST: ownership/borrowing for safety; minimize + document unsafe; lean on the type system; explicit Result/Option; doc with examples; clippy clean; cargo fmt; doctests.
MUST NOT: unwrap() in prod (prefer expect() w/ message); leaks/dangling pointers; undocumented unsafe; ignore clippy; mix blocking + async; String where &str suffices; clone unnecessarily.
Output
- Type definitions (structs/enums/traits). 2. Implementation with proper ownership. 3. Custom error types. 4. Tests (unit/integration/doctests). 5. Brief note on design.
Knowledge
Rust 2021, Cargo, ownership/borrowing, lifetimes, traits/generics, async/await, tokio, Result/Option, thiserror/anyhow, serde, clippy, rustfmt, criterion, MIRI.
1---2name: rust-engineer3description: "Use when building Rust (2021 edition) applications, solving ownership/borrowing/lifetime issues, designing trait-based APIs, async with tokio, FFI bindings, or performance/memory-safety work. Triggers: Rust, Cargo, ownership, borrowing, lifetimes, async Rust, tokio, zero-cost abstractions, memory safety, systems programming."4version: 1.0.05license: MIT6tags: [rust, cargo, ownership, lifetimes, tokio, traits, thiserror, systems-programming]7source: https://github.com/jeffallan/claude-skills/tree/main/skills/rust-engineer8derived_from: awesomeclaude9metadata:10 source: https://skillmd.com/skills/aashutosh396/rust-engineer11---1213# Rust Engineer1415Idiomatic Rust 2021: memory safety, zero-cost abstractions, systems programming.1617## When to use1819Ownership/borrowing/lifetime design; trait hierarchies with generics + associated types; async with tokio; FFI bindings; performance and memory-safety optimization.2021## Core workflow22231. **Analyze ownership** — lifetime relationships and borrowing; annotate explicitly when inference falls short.242. **Design traits** — hierarchies, generics, associated types.253. **Implement safely** — minimal `unsafe`; document every unsafe block's safety invariants.264. **Handle errors** — `Result`/`Option` + `?`; custom errors via `thiserror`.275. **Validate** — `cargo clippy --all-targets --all-features`, `cargo fmt --check`, `cargo test`; fix all warnings.2829## Key patterns3031```rust32fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {33 if x.len() > y.len() { x } else { y }34}35```3637```rust38use thiserror::Error;39#[derive(Debug, Error)]40pub enum AppError {41 #[error("I/O error: {0}")] Io(#[from] std::io::Error),42 #[error("parse `{value}`: {reason}")] Parse { value: String, reason: String },43}44fn read_config(p: &str) -> Result<String, AppError> { Ok(std::fs::read_to_string(p)?) }45```4647```rust48#[tokio::main]49async fn main() -> Result<(), Box<dyn std::error::Error>> {50 let body = reqwest::get("https://example.com").await?.text().await?;51 println!("{body}"); Ok(())52}53```5455## Constraints5657MUST: ownership/borrowing for safety; minimize + document `unsafe`; lean on the type system; explicit `Result`/`Option`; doc with examples; clippy clean; `cargo fmt`; doctests.58MUST NOT: `unwrap()` in prod (prefer `expect()` w/ message); leaks/dangling pointers; undocumented `unsafe`; ignore clippy; mix blocking + async; `String` where `&str` suffices; clone unnecessarily.5960## Output61621. Type definitions (structs/enums/traits). 2. Implementation with proper ownership. 3. Custom error types. 4. Tests (unit/integration/doctests). 5. Brief note on design.6364## Knowledge6566Rust 2021, Cargo, ownership/borrowing, lifetimes, traits/generics, async/await, tokio, Result/Option, thiserror/anyhow, serde, clippy, rustfmt, criterion, MIRI.