rust
1
总安装量
1
周安装量
#49131
全站排名
安装命令
npx skills add https://github.com/g1joshi/agent-skills --skill rust
Agent 安装分布
mcpjam
1
claude-code
1
replit
1
junie
1
zencoder
1
Skill 文档
Rust
A language empowering everyone to build reliable and efficient software.
When to Use
- Systems programming (drivers, OS)
- WebAssembly
- Performance-critical applications
- Command-line tools (great developer experience)
Quick Start
fn main() {
println!("Hello, World!");
let mut x = 5; // mutable
x = 6;
let y = 10; // immutable by default
}
Core Concepts
Ownership & Borrowing
The borrow checker ensures rules are followed at compile time.
- Each value has a single owner.
- You can have multiple immutable borrows OR one mutable borrow, but not both simultaneously.
Lifetimes
Ensuring references remain valid for as long as they are used.
Traits
Similar to interfaces, defining shared behavior.
Best Practices
Do:
- Embrace the borrow checker (it’s your friend)
- Use
Result<T, E>andOption<T>for error handling - Use
cargo clippyfor linting - Use
matchfor exhaustive pattern matching
Don’t:
- Use
unsafeunless absolutely necessary unwrap()in production code (use proper error handling)