rust-dev-guidelines

Write idiomatic Rust code with async patterns and error handling.

6|Updated Jan 17, 2023
One-click install
npx skills add https://github.com/ocn/zk-activity --skill rust-dev-guidelines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-dev-guidelines
Source: https://github.com/ocn/zk-activity/tree/main/.claude/skills/rust-dev-guidelines
Command: npx skills add https://github.com/ocn/zk-activity --skill rust-dev-guidelines

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to writing idiomatic Rust code, focusing on patterns essential for asynchronous applications, error handling, and efficient resource management.

Core Features & Use Cases

  • Error Handling: Master Result/Option and the ? operator for robust error propagation.
  • Async Programming: Implement asynchronous operations efficiently using Tokio, including spawning tasks and concurrent execution.
  • Resource Management: Understand ownership, borrowing, and safe sharing of state with Arc and RwLock.
  • Use Case: When developing a new Rust microservice or refactoring an existing one, consult this Skill to ensure adherence to best practices for async operations, error handling, and concurrency.

Quick Start

Use the rust-dev-guidelines skill to understand how to handle errors in an asynchronous Rust function.

Frequently Asked Questions about rust-dev-guidelines

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the best way to handle errors in async Rust functions?

The best way to handle errors in async Rust is using the `Result` and `Option` types with the `?` operator for robust, simplified error propagation across asynchronous boundaries without unwinding the stack.

How do I share state across concurrent Tokio tasks in Rust?

To share state across concurrent Tokio tasks, wrap your data in `Arc` and `Mutex` or `RwLock`. This allows multiple asynchronous tasks to safely access and modify shared memory without data races.

Does idiomatic Rust require Tokio for async programming?

Tokio is heavily utilized in idiomatic Rust for async programming because it provides the runtime necessary for spawning tasks and executing concurrent operations efficiently, as outlined by async best practices.

How do I avoid common async Rust anti-patterns when refactoring?

To avoid async Rust anti-patterns during refactoring, adhere to clippy best practices, ensure proper ownership and borrowing, and use `serde` serialization guidelines to maintain idiomatic code structure.

When should I use traits and generics in asynchronous Rust applications?

Use traits and generics in asynchronous Rust applications when you need to define shared behavior across different types or require flexible, reusable components that integrate seamlessly with Tokio's async execution model.