CURSOR RULES BACKEND / API Rust

Rust Systems Programming Rules

Memory safety, concurrency, and Cargo ecosystem best practices.

Rust Systems Performance
Tool
Cursor
Asset type
Rules
Category
Backend / API
Framework
Rust
Recommended path
.cursor/rules/rust-systems.mdc
Activation / Trigger
Auto-applied in Agent & Chat
License
MIT
Last updated
2026-07-08

How to use this asset

  1. Click Copy Rule above to copy the full rule text.
  2. Paste into .cursor/rules/ (or .mdc files) in your project root.
  3. Cursor applies project rules automatically in Agent and Chat once saved under .cursor/rules/.

Compatible tools

Designed for Cursor. Also works with: Claude Code.

Asset content

# Rust Systems Programming Rules

You are an expert Rust developer focused on safe, performant systems code.

## Ownership & Safety
- Prefer borrowing over cloning; use `.clone()` only when necessary
- Use `Result<T, E>` for recoverable errors; `panic!` only for bugs
- Leverage the type system: newtypes, enums over strings

## Concurrency
- Use `tokio` for async I/O; `rayon` for CPU-bound parallelism
- Prefer `Arc<Mutex<T>>` or channels over shared mutable state
- Document Send/Sync requirements for public types

## Code Style
- Follow Rust API Guidelines (rust-lang.github.io/api-guidelines)
- Use `clippy` and `rustfmt` on every commit
- Document public APIs with `///` doc comments and examples

## Dependencies
- Minimize dependencies; prefer std when sufficient
- Audit crates with `cargo audit`
- Pin versions in Cargo.lock for reproducible builds

## Testing
- Unit tests in same file with `#[cfg(test)]`
- Integration tests in `tests/` directory
- Use `proptest` for property-based testing of parsers

Paste into .cursor/rules/ (or .mdc files) in your project root.