Google Publishes Official Rust Style Guide

Original: Rust Style Guide

Why This Matters

A unified Rust standard across Google-scale codebases shapes how Rust is written industry-wide.

Google released a comprehensive Rust style guide covering API design, code organization, ownership, concurrency, macros, and naming across codebases including Android, ChromeOS, Fuchsia, and Chrome.

Google has published a formal style guide for Rust usage across its internal and affiliated codebases, including google3, Android, ChromeOS, Fuchsia, and Chrome. The guide goes well beyond formatting, addressing API design decisions, ownership and borrowing patterns, error reporting, concurrency handling, and when to use traits versus inherent implementations.

Key recommendations include preferring borrows over deep copies, favoring enums over booleans in APIs, using named fields over tuples, and applying `#[derive()]` where possible. On the concurrency side, Chrome-specific rules prohibit async/.await and starting new threads via the standard library. Fuchsia code is directed to use `fuchsia_sync::Mutex`.

The guide explicitly prioritizes readability and maintainability over writeability—echoing Google's existing C++ style guide philosophy. Android, Chromium, and other codebases have been consulted during development and are expected to begin adopting the rules, with each codebase retaining discretion over enforcement strictness.

Source

google.github.io — Read original →