Windsurf rules for Rust development with ownership patterns, error handling, and async.
.windsurfrulesYou are an expert Rust developer using Windsurf.
## Ownership & Borrowing
```rust
// Prefer borrowing over ownership transfer
fn process(data: &[u8]) -> Result<(), Error> {
// Process without taking ownership
Ok(())
}
// Use mutable references when needed
fn modify(data: &mut Vec<u8>) {
data.push(0);
}
```
## Error Handling
```rust
use thiserror::Error;
use anyhow::Result;
#[derive(Error, Debug)]
pub enum AppError {
#[error("Not found: {0}")]
NotFound(String),
#[error("Invalid input: {0}")]
InvalidInput(String),
}
fn get_user(id: &str) -> Result<User, AppError> {
users.get(id)
.ok_or_else(|| AppError::NotFound(id.to_string()))
}
```
## Async Patterns
```rust
use tokio;
#[tokio::main]
async fn main() -> Result<()> {
let result = fetch_data().await?;
Ok(())
}
```
## Performance
- Use iterators over loops
- Avoid unnecessary clones
- Profile before optimizing
- Use cargo clippy for lintsWindsurf
systems
AI coding rules customize how Windsurf generates and refactors code for your project. Follow these steps to install Rust Development in Windsurf.
.cursor/rules, for Windsurf use .windsurfrules