sunsided / rust-guidelines

Coding guidelines for Rust, with examples

Repository from Github https://github.comsunsided/rust-guidelinesRepository from Github https://github.comsunsided/rust-guidelines

Rust Coding Guidelines

Human-friendly and AI-compatible guidelines for building robust, maintainable, and idiomatic Rust applications

Rust License

🎯 Purpose

This repository provides comprehensive, practical guidelines for Rust development, especially focused on async and service-oriented applications. Whether you're building web services, CLI tools, or distributed systems, these guidelines help you write code that is:

  • βœ… Robust β€” Handle errors gracefully and avoid common pitfalls
  • βœ… Maintainable β€” Clear structure and consistent patterns
  • βœ… Idiomatic β€” Follow Rust community best practices
  • βœ… AI-Compatible β€” Structured for both human developers and AI assistants

πŸ“– Guidelines

πŸ‘‰ Read the Complete Guidelines

The guidelines cover everything from project setup to advanced API design:

πŸ—οΈ Project Foundation

  • Latest Rust edition usage
  • Workspace management
  • Configuration and secrets handling

🎨 Code Organization

  • Feature-based module structure
  • Dependency injection patterns
  • Documentation standards

⚑ Error Handling & Safety

  • thiserror and specific error types
  • Input validation strategies
  • Compile-time safety patterns

πŸš€ Async & Runtime

  • Tokio runtime best practices
  • Graceful shutdown patterns

πŸ§ͺ Testing & Quality

  • Unit, integration, and property-based testing
  • Logging and tracing setup

🏷️ Naming & API Design

  • Consistent naming conventions
  • Ownership and borrowing guidelines
  • Generic bounds and where clauses

πŸš€ Quick Start

  1. Browse the guidelines: Start with guidelines.md
  2. Apply to your project: Use the patterns and examples provided
  3. Contribute: Found something missing? Open an issue or PR!

🎯 Who This Is For

  • Rust developers building production applications
  • Teams establishing coding standards
  • AI assistants needing structured Rust guidance
  • Anyone wanting to write better Rust code

🀝 Contributing

These guidelines are living documents that evolve with the Rust ecosystem. Contributions, suggestions, and discussions are welcome!

πŸ“„ License

This project is licensed under either of

  • EUPL v1.2
  • Apache License, Version 2.0
  • MIT License

at your option.


Happy coding! πŸ¦€

About

Coding guidelines for Rust, with examples


Languages

Language:Rust 100.0%