rust

v2026.09.24

Rust language patterns and ecosystem covering ownership, borrowing, lifetimes, error handling (Result/Option, thiserror, anyhow), async with Tokio, traits, generics, serde serialization, Cargo workspaces, and testing. Includes axum web framework, ratatui terminal UI, clap CLI parsing, criterion benchmarking, cargo-deny supply chain security, cargo-dist binary distribution, and release-plz changelog automation. Use when writing Rust code, designing ownership models, building async services with Tokio/axum, creating terminal UIs with ratatui, setting up CLI applications with clap, configuring CI/CD pipelines for Rust, benchmarking with criterion, auditing dependencies with cargo-deny, or distributing binaries with cargo-dist.

GitHub
安装命令
npx skhub add oakoss/rust
Markdown
SKILL.md

Rust

Overview

Rust is a systems programming language focused on safety, concurrency, and performance. The ownership system guarantees memory safety without garbage collection, and the type system enforces thread safety at compile time.

When to use: Systems programming, web services (axum), CLI tools (clap), terminal UIs (ratatui), WebAssembly, performance-critical applications, anything requiring memory safety without runtime overhead.

When NOT to use: Rapid prototyping where compile times matter more than safety, simple scripting tasks, projects where the team has no Rust experience and deadlines are tight.

Quick Reference

PatternAPI / ToolKey Points
Ownership transferlet b = a;a is moved, no longer usable
Borrowing&T / &mut TOne mutable OR many immutable refs
Lifetime annotationfn f<'a>(x: &'a str) -> &'a strTies output lifetime to input
Error propagation? operatorConverts and propagates errors
Custom errorsthiserror::Error deriveStructured error types with Display
Ad-hoc errorsanyhow::Result<T>Context chaining for applications
Async runtime#[tokio::main]Entry point for async programs
Spawn tasktokio::spawn(async { })Concurrent async task execution
HTTP routeraxum::Router::new().route(...)Composable routing with extractors
ExtractorsJson<T>, Path<T>, State<T>Type-safe request parsing
Serialization#[derive(Serialize, Deserialize)]serde with format-agnostic derives
CLI parsing#[derive(Parser)]clap derive API for arg parsing
TUI renderingterminal.draw(|f| { })Immediate-mode ratatui rendering
Benchmarkingcriterion::CriterionStatistical benchmarking framework
Dep auditingcargo deny checkLicense, vulnerability, source audit
Binary releasecargo dist initCross-platform binary distribution
Changelogrelease-plz updateAuto semver bump and changelog

Common Mistakes

MistakeCorrect Pattern
Returning reference to local variableReturn owned type or use lifetime parameter
Using unwrap() in library codeReturn Result and let caller decide
clone() to satisfy borrow checkerRestructure code to avoid the borrow conflict
Blocking in async contextUse tokio::task::spawn_blocking
Shared mutable state without syncUse Arc<Mutex<T>> or channels
String where &str sufficesAccept &str in function parameters
Ignoring must_use warningsHandle or explicitly discard with let _ =
Large enum variantsBox the large variant to reduce overall size
async fn in traits without boundsAdd Send bound or use async-trait crate
Missing #[tokio::test] on async testsUse #[tokio::test] instead of #[test]

Delegation

  • Code exploration: Use Explore agent
  • Architecture review: Use Task agent
  • Code review: Delegate to code-reviewer agent

If the docker skill is available, delegate multi-stage container build patterns to it. If the github-actions skill is available, delegate CI pipeline configuration to it. If the openapi skill is available, delegate API specification and code generation to it.

References

发现
标签

此技能尚未发布标签。

版本
最新版本元数据

版本

v2026.09.24

发布时间

Sep 24, 2026

分类

未分类

许可证

未指定

源路径

skills/rust

默认分支

main

最新提交

85e3a39

Tree SHA

a4c9e7b