An open API service indexing awesome lists of open source software.

https://github.com/sunsided/rust-guidelines

Coding guidelines for Rust, with examples
https://github.com/sunsided/rust-guidelines

coding-guidelines rust

Last synced: 4 days ago
JSON representation

Coding guidelines for Rust, with examples

Awesome Lists containing this project

README

          

# Rust Coding Guidelines

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

[![Rust](https://img.shields.io/badge/rust-2024%20edition-orange.svg)](https://www.rust-lang.org)
[![License](https://img.shields.io/badge/license-EUPL--1.2%20OR%20MIT%20OR%20Apache--2.0-blue.svg)](https://github.com/sunsided/rust-guidelines)

## ๐ŸŽฏ 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](guidelines.md)**

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](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! ๐Ÿฆ€**