Cursor rule
.cursor/rules/rust-async-development-rules.mdc[object Object]
Cursor rules
Quality
38/100
Scores the file, not the repository.Length
482 words
0 headings · 0 code blocksRepository
0
— · pushed 434 days agoLast changed
3 days ago
First indexed 3 days ago.123456You are an expert in Rust, async programming, and concurrent systems.78Key Principles9- Write clear, concise, and idiomatic Rust code with accurate examples.10- Use async programming paradigms effectively, leveraging `tokio` for concurrency.11- Prioritize modularity, clean code organization, and efficient resource management.12- Use expressive variable names that convey intent (e.g., `is_ready`, `has_data`).13- Adhere to Rust's naming conventions: snake_case for variables and functions, PascalCase for types and structs.14- Avoid code duplication; use functions and modules to encapsulate reusable logic.15- Write code with safety, concurrency, and performance in mind, embracing Rust's ownership and type system.16- Make sure generated code is free from compiler errors regenerating if necessary.1718Async Programming19- Use `tokio` as the async runtime for handling asynchronous tasks and I/O.20- Implement async functions using `async fn` syntax.21- Leverage `tokio::spawn` for task spawning and concurrency.22- Use `tokio::select!` for managing multiple async tasks and cancellations.23- Favor structured concurrency: prefer scoped tasks and clean cancellation paths.24- Implement timeouts, retries, and backoff strategies for robust async operations.2526Channels and Concurrency27- Use Rust's `tokio::sync::mpsc` for asynchronous, multi-producer, single-consumer channels.28- Use `tokio::sync::broadcast` for broadcasting messages to multiple consumers.29- Implement `tokio::sync::oneshot` for one-time communication between tasks.30- Prefer bounded channels for backpressure; handle capacity limits gracefully.31- Use `tokio::sync::Mutex` and `tokio::sync::RwLock` for shared state across tasks, avoiding deadlocks.3233Error Handling and Safety34- Embrace Rust's Result and Option types for error handling.35- Use `?` operator to propagate errors in async functions.36- Implement custom error types using `thiserror` or `anyhow` for more descriptive errors.37- Handle errors and edge cases early, returning errors where appropriate.38- Use `.await` responsibly, ensuring safe points for context switching.3940Testing41- Write unit tests with `tokio::test` for async tests.42- Use `tokio::time::pause` for testing time-dependent code without real delays.43- Implement integration tests to validate async behavior and concurrency.44- Use mocks and fakes for external dependencies in tests.4546Performance Optimization47- Minimize async overhead; use sync code where async is not needed.48- Avoid blocking operations inside async functions; offload to dedicated blocking threads if necessary.49- Use `tokio::task::yield_now` to yield control in cooperative multitasking scenarios.50- Optimize data structures and algorithms for async use, reducing contention and lock duration.51- Use `tokio::time::sleep` and `tokio::time::interval` for efficient time-based operations.5253Key Conventions541. Structure the application into modules: separate concerns like networking, database, and business logic.552. Use environment variables for configuration management (e.g., `dotenv` crate).563. Ensure code is well-documented with inline comments and Rustdoc.5758Async Ecosystem59- Use `tokio` for async runtime and task management.60- Leverage `hyper` or `reqwest` for async HTTP requests.61- Use `serde` for serialization/deserialization.62- Use `sqlx` or `tokio-postgres` for async database interactions.63- Utilize `tonic` for gRPC with async support.6465Refer to Rust's async book and `tokio` documentation for in-depth information on async patterns, best practices, and advanced features.
Also in alexwine36/serpeo
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| alexwine36/serpeo.cursor/rules/general.mdc · 0 | Cursor rules | no sections | 24/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| nerds-odd-e/doughnut.cursor/rules/cli.mdc · 49 | Cursor rules | setupbuildteststyle+4 | 96/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/proto.mdc · 126 | Cursor rules | buildlint-formatstylearch+3 | 96/100 | 3 days ago | |
| K-Mistele/opensearch.cursor/rules/default.mdc · 30 | Cursor rules | buildtestlint-formatstyle+2 | 94/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/task-context-loading.mdc · 126 | Cursor rules | archtypesdatabasedo-not+1 | 93/100 | 3 days ago |
