claudegoodies
Skill

rust-patterns

From affaan-m

Patrones idiomáticos de Rust, ownership, manejo de errores, traits, concurrencia y buenas prácticas para construir aplicaciones seguras y eficientes.

Provides Rust code conventions covering ownership, error handling, enums, traits, and concurrency patterns.

Use it when

  • Writing new Rust code or reviewing existing Rust code
  • Refactoring Rust modules or crate structure
  • Deciding between thiserror and anyhow for error handling
  • Designing enum-based state machines or trait abstractions

Skip it if

  • Only useful for Rust projects, no other language covered
  • It's a reference document, not an executable tool or linter
  • Content is in Spanish

Facts

Repository
affaan-m/ECC
Status
Actively maintained
Last commit

Source preview

The instructions Claude Code reads when this skill runs.

# Patrones de Desarrollo Rust

Patrones idiomáticos y buenas prácticas de Rust para construir aplicaciones seguras, eficientes y mantenibles.

## Cuándo Usar

- Escribir código Rust nuevo
- Revisar código Rust
- Refactorizar código Rust existente
- Diseñar la estructura de crates y la organización de módulos

## Cómo Funciona

Este skill refuerza las convenciones idiomáticas de Rust en seis áreas clave: ownership y borrowing para prevenir data races en tiempo de compilación, propagación de errores con `Result`/`?` usando `thiserror` para bibliotecas y `anyhow` para aplicaciones, enums y pattern matching exhaustivo para hacer imposibles los estados inválidos, traits y genéricos para abstracciones de costo cero, concurrencia segura con `Arc<Mutex<T>>`, canales y async/await, y superficies `pub` mínimas organizadas por dominio.

## Principios Fundamentales

### 1. Ownership y Borrowing

El sistema de ownership de Rust previene data races y bugs de memoria en tiempo de compilación.

```rust
// Bien: Pasar referencias cuando no se necesita el ownership
fn process(data: &[u8]) -> usize {
    data.len()
}

// Bien: Tomar ownership solo cuando se necesita almacenar o consumir
fn store(data: Vec<u8>) -> Record {
    Record { payload: data }
}

// Mal: Clonar innecesariamente para evitar el borrow checker
fn process_bad(data: &Vec<u8>) -> usize {
    let cloned = data.clone(); // Costoso
View full source on GitHub →

Other skills