maverick-rust-async
Rust异步/await与Tokio及异步模式
📖 中文导读:Rust异步/await与Tokio及异步模式 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: maverick-rust-async description: Rust async/await with Tokio and async patterns version: 1.0.0 triggers: - async fn - .await - tokio - async move - Future - Pin - Send - Sync - spawn - JoinHandle
Rust Async Skill
Tokio Basics
#[tokio::main]
async fn main() {
let result = fetch_data().await;
}
async fn fetch_data() -> Result<String, Error> {
// async operation
}
Spawning Tasks
let handle = tokio::spawn(async move {
expensive_operation().await
});
let result = handle.await?;
Send + Sync Bounds
Send: Can transfer across thread boundariesSync: Can be shared across threads (&T is Send)- Use
Arcinstead ofRcfor thread-safe reference counting
Review Severity
- CRITICAL: Blocking calls in async functions
- MAJOR: Using Rc in async code (not Send)
- MINOR: Not using async context managers