用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill rust命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | rust |
| description | | Use when this capability is needed. |
Full Reference: See advanced.md for builder pattern, advanced traits, async patterns (join!/select!/spawn), custom errors with thiserror, and production configuration.
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:rustfor comprehensive documentation.
Rust's memory safety is guaranteed through its ownership system without a garbage collector.
fn main() {
let s1 = String::from("hello");
let s2 = s1; // s1 is MOVED to s2
// println!("{s1}"); // ERROR: s1 is no longer valid
println!("{s2}"); // OK: s2 owns the data
}
fn main() {
let x = 5;
let y = x; // x is COPIED (not moved)
println!("x = {x}, y = {y}"); // Both valid
}
Types implementing Copy trait:
u32, i64, etc.)bool)f64)char)fn main() {
let s1 = String::from("hello");
let s2 = s1.clone(); // Explicit deep copy
println!("s1 = {s1}, s2 = {s2}"); // Both valid
}
fn main() {
let s1 = String::from("hello");
let len = calculate_length(&s1); // Borrow s1
println!("Length of '{s1}' is {len}"); // s1 still valid
}
fn calculate_length(s: &String) -> usize {
s.len()
} // s goes out of scope but doesn't drop data (just a reference)
fn main() {
let mut s = String::from("hello");
change(&mut s);
println!("{s}"); // Prints "hello, world"
}
fn change(s: &mut String) {
s.push_str(", world");
}
fn main() {
let mut s = String::from("hello");
let r1 = &s; // OK: first immutable borrow
let r2 = &s; // OK: second immutable borrow
println!("{r1} and {r2}");
// r1 and r2 no longer used after this point
let r3 = &mut s; // OK: mutable borrow (after immutables are done)
println!("{r3}");
}
Lifetimes ensure references are valid for as long as they're used.
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
if x.len() > y.len() { x } else { y }
}
fn main() {
let string1 = String::from("long string");
let result;
{
let string2 = String::from("xyz");
result = longest(string1.as_str(), string2.as_str());
println!("Longest: {result}"); // Must use result here
}
// Can't use result here - string2 dropped
}
The compiler applies these rules automatically:
&self or &mut self, output gets self's lifetimelet s: &'static str = "I live forever";
use std::fs::File;
use std::io::{self, Read};
fn read_username_from_file() -> Result<String, io::Error> {
let mut file = File::open("hello.txt")?; // ? propagates errors
let mut username = String::new();
file.read_to_string(&mut username)?;
Ok(username)
}
// Even shorter with fs::read_to_string
fn read_username_shortest() -> Result<String, io::Error> {
std::fs::read_to_string("hello.txt")
}
fn find_user(id: u32) -> Option<User> {
users.iter().find(|u| u.id == id).cloned()
}
// Using Option
match find_user(42) {
Some(user) => println!("Found: {}", user.name),
None => println!("User not found"),
}
// Combinators
let name = find_user(42)
.map(|u| u.name)
.unwrap_or_else(|| "Anonymous".to_string());
async fn fetch_data(url: &str) -> Result<String, reqwest::Error> {
let response = reqwest::get(url).await?;
let body = response.text().await?;
Ok(body)
}
#[tokio::main]
async fn main() {
match fetch_data("https://api.example.com").await {
Ok(data) => println!("Got: {data}"),
Err(e) => eprintln!("Error: {e}"),
}
}
#[derive(Debug, Clone)]
pub struct User {
pub id: u64,
pub name: String,
pub email: String,
active: bool, // private field
}
impl User {
// Associated function (constructor)
pub fn new(id: u64, name: String, email: String) -> Self {
Self {
id,
name,
email,
active: true,
}
}
// Method with immutable borrow
pub fn is_active(&self) -> bool {
self.active
}
// Method with mutable borrow
pub fn deactivate(&mut self) {
self.active = false;
}
}
pub trait Summary {
fn summarize(&self) -> String;
// Default implementation
fn summarize_author(&self) -> String {
String::from("Unknown author")
}
}
impl Summary for Article {
fn summarize(&self) -> String {
format!("{}, by {}", self.headline, self.author)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
pub struct Config {
pub host: String,
pub port: u16,
}
my_project/
├── Cargo.toml
├── Cargo.lock
├── src/
│ ├── main.rs # Binary entry point
│ ├── lib.rs # Library root
│ └── module/ # Module directory
│ └── mod.rs
├── tests/ # Integration tests
├── benches/ # Benchmarks
└── examples/ # Example programs
[package]
name = "my_project"
version = "0.1.0"
edition = "2021"
[dependencies]
tokio = { version = "1.0", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
[dev-dependencies]
tokio-test = "0.4"
[profile.release]
opt-level = 3
lto = true
cargo new my_project # Create new project
cargo build # Build debug
cargo build --release # Build optimized
cargo run # Build and run
cargo test # Run tests
cargo doc --open # Generate docs
cargo clippy # Lint code
cargo fmt # Format code
cargo check # Fast type checking
| Scenario | Use Instead |
|---|---|
| Actix/Axum framework specifics | Framework-specific skills |
| Tauri desktop apps | tauri skill |
| WebAssembly compilation | WASM-specific skill |
| Diesel ORM | ORM-specific skill |
| Rocket web framework | Framework-specific skill |
| Anti-Pattern | Why It's Bad | Correct Approach |
|---|---|---|
.clone() everywhere | Unnecessary allocations | Use references or Arc |
.unwrap() in production | Panics on error | Use proper error handling |
Large match statements | Hard to maintain | Use methods or polymorphism |
| Ignoring Clippy warnings | Misses best practices | Fix all warnings |
Not using ? operator | Verbose error handling | Use ? for propagation |
| Mutex for everything | Lock contention | Use channels or RwLock |
| Blocking in async | Blocks executor | Use spawn_blocking |
| Manual memory management | Defeats ownership | Trust the compiler |
| Issue | Cause | Solution |
|---|---|---|
| "cannot borrow as mutable" | Multiple borrows | Drop immutable refs first |
| "move occurs because X has type Y" | Ownership moved | Clone or use references |
| "lifetime may not live long enough" | Lifetime mismatch | Add lifetime annotations |
| "trait X is not implemented" | Missing trait impl | Implement trait or derive |
| "cannot return reference to local" | Dangling reference | Return owned value |
| "cyclic dependency detected" | Circular deps | Refactor dependency tree |
| Slow compilation | Too many dependencies | Use cargo workspaces |
| Memory leak with Arc | Circular references | Use Weak references |
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:rustfor comprehensive documentation.
Source: claude-dev-suite/claude-dev-suite — distributed by TomeVault.