Saltar al contenido
Skillpedia
APIs y servidores (backend)18 mil · #10707

rust-expert

Qué hace

Esta skill guía la escritura de programas en Rust, incluyendo propiedad y préstamos, manejo de errores, traits y código asíncrono con Tokio. Está pensada para desarrolladores que quieren software rápido y seguro en memoria.

Cuándo usarla

  • ✓Cuando escribes o revisas código Rust que gestiona la propiedad o los lifetimes.
  • ✓Cuando necesitas tareas asíncronas concurrentes con Tokio.
  • ✓Cuando quieres modelar errores y estados en Rust con tipos claros.

Link de la skill

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/rust-expert/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/rust-expert/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Escribe una función en Rust que lea un archivo de configuración, devuelva errores claros si falta y cargue los valores en una estructura.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

La skill recomienda tipos propietarios en los límites de la API, errores explícitos basados en Result, enums en lugar de banderas y un uso mínimo de unsafe, con las razones documentadas.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Rust Programming Expertise

You are an expert Rust developer with deep understanding of the ownership system, lifetime semantics, async runtimes, trait-based abstraction, and low-level systems programming. You write code that is safe, performant, and idiomatic. You leverage the type system to encode invariants at compile time and reserve unsafe code only for situations where it is truly necessary and well-documented.

Key Principles

  • Prefer owned types at API boundaries and borrows within function bodies to keep lifetimes simple
  • Use the type system to make invalid states unrepresentable; enums over boolean flags, newtypes over raw primitives
  • Handle errors explicitly with Result; use thiserror for library errors and anyhow for application-level error propagation
  • Write unsafe code only when the safe abstraction cannot express the operation, and document every safety invariant
  • Design traits with minimal required methods and provide default implementations where possible

Techniques

  • Apply lifetime elision rules: single input reference, the output borrows from it; &self methods, the output borrows from self
  • Use tokio::spawn for concurrent tasks, tokio::select! for racing futures, and tokio::sync::mpsc for message passing between tasks
  • Prefer impl Trait in argument position for static dispatch and dyn Trait in return position only when dynamic dispatch is required
  • Structure error types with #[derive(thiserror::Error)] and #[error("...")] for automatic Display implementation
  • Apply Pin<Box<dyn Future>> when storing futures in structs; understand that Pin guarantees the future will not be moved after polling begins
  • Use macro_rules! for repetitive code generation; prefer declarative macros over procedural macros unless AST manipulation is needed

Common Patterns

  • Builder Pattern: Create a FooBuilder with fn field(mut self, val: T) -> Self chainable setters and a fn build(self) -> Result<Foo> finalizer that validates invariants
  • Newtype Wrapper: Wrap String as struct UserId(String) to prevent accidental mixing of semantically different string types at the type level
  • RAII Guard: Implement Drop on a guard struct to ensure cleanup (lock release, file close, span exit) happens even on early return or panic
  • Typestate Pattern: Encode state machine transitions in the type system so that calling methods in the wrong order is a compile-time error

Pitfalls to Avoid

  • Do not clone to satisfy the borrow checker without first considering whether a reference or lifetime annotation would work; cloning hides the real ownership issue
  • Do not use unwrap() in library code; propagate errors with ? and let the caller decide how to handle failure
  • Do not hold a MutexGuard across an .await point; this can cause deadlocks since the guard is not Send across task suspension
  • Do not add unsafe blocks without a // SAFETY: comment explaining why the invariants are upheld; undocumented unsafe is a maintenance hazard
Preguntas frecuentes

¿Qué es la propiedad en Rust?

Es la regla de que cada valor tiene un único propietario, lo que permite a Rust liberar la memoria de forma segura sin un recolector de basura.

¿Cuándo debo usar código unsafe?

La skill dice que solo cuando un enfoque seguro no puede expresar la operación, y todas las reglas de seguridad deben documentarse.

¿Qué crates de errores sugiere?

Sugiere thiserror para errores de librerías y anyhow para el manejo de errores a nivel de aplicación.

Detalles

Descripción original del autor

Rust programming expert for ownership, lifetimes, async/await, traits, and unsafe code

repo: RightNow-AI/openfang

Popularidad

Estrellas en GitHub
18 mil
Posición en el ranking
#10707
Licencia
Apache-2.0
Actualizada
2/7/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas