Google's Rust Style Guide: rustfmt wins, and the arguments are over

4 min read 1 source clear_take
├── "The guide's thinness is a sign of a mature language ecosystem"
│  ├── top10.dev editorial (top10.dev) → read below

The editorial argues that Google's decision to defer almost entirely to rustfmt's defaults is itself the headline. Unlike the sprawling C++ guide full of carve-outs for a language with poor defaults, the Rust guide can be short because rustfmt and clippy already solved the hard problems — a vindication of the Rust project's design choices.

│  └── @kaycebasques (Hacker News, 295 pts) → view

The submitter and top HN commenters converge on the view that this is what a mature style guide looks like — concise, deferring to community tooling rather than inventing a house style. The 295-point submission reflects broad agreement that Rust's ecosystem has reached a level of maturity where even Google doesn't feel the need to override defaults.

├── "Google's endorsement will shape industry Rust practice beyond Google itself"
│  └── top10.dev editorial (top10.dev) → read below

The editorial draws a historical parallel: Google's C++ guide became the de facto industry standard, its Python guide influenced Black's design, and its Go guide essentially defines idiomatic Go. Given Google's aggressive adoption of Rust in Android, Chromium, and Fuchsia, this guide carries unusual weight and will likely cascade into how other large organizations write Rust.

└── "The substantive value lies in guidance where tooling can't help"
  └── Google (via style guide) (google.github.io/styleguide) → read

Google's guide concentrates its opinionated content on areas rustfmt and clippy don't automate: naming conventions, Result-vs-panic error handling, mod.rs structure, and documenting safety invariants on unsafe blocks. The implicit argument is that formatters solve mechanical consistency, but humans still need written norms for semantic decisions like when to panic or how to justify unsafe code.

What happened

Google published its official Rust Style Guide at `google.github.io/styleguide/rustguide.html`, formally adding Rust to the same canonical style collection that houses the long-running C++, Java, Python, and Go guides. The document covers formatting, naming, error handling, module layout, use of `unsafe`, panics, documentation, and interop with Google's internal build system. It joins a growing roster of Rust style guides from large organizations — but Google's carries unusual weight because of how aggressively the company has moved Rust into Android, Chromium, and Fuchsia over the past four years.

The headline decision: Google defers to rustfmt's default configuration for virtually all formatting questions, explicitly declining to invent a house style. No argument over tab width, no custom import ordering, no opinionated max line length. Where the Rust project has already decided something, Google adopts it. The guide's substantive content is concentrated in the places rustfmt doesn't reach — naming conventions, when to use `Result` vs panic, how to structure `mod.rs` files, and how to document safety invariants on `unsafe` blocks.

On Hacker News, the submission hit 295 points with the top comments converging on a single observation: this is what a mature style guide looks like. Google's C++ guide, by contrast, is a 20-year-old scar tissue document littered with carve-outs for a language that didn't give its users good defaults. The Rust guide is short because `rustfmt` and `clippy` already did the hard work.

Why it matters

Style guides from Google historically shape industry practice far beyond Mountain View. The C++ guide became the de facto standard for a generation of systems teams; the Python guide influenced Black's design; the Go guide essentially *is* idiomatic Go because Google wrote the language. The Rust guide's deliberate thinness is itself the statement — Google is signaling that the Rust community got the defaults right the first time.

Compare this to the C++ guide's famous eccentricities: ban on exceptions, restrictions on operator overloading, idiosyncratic rules around `std::unique_ptr` ownership patterns. Those exist because C++ gives you ten ways to shoot yourself and Google had to pick which gun to confiscate. Rust's borrow checker and `Result`-based error handling preempt most of those decisions, so the guide can focus on genuinely contested questions — like whether to use `anyhow` and `thiserror` in library code (Google says no for public APIs, yes for internal binaries) or how to spell constructors on types that can fail (prefer `new() -> Result` over `try_new`).

The `unsafe` guidance is where Google adds real value. The guide requires every `unsafe` block to carry a `// SAFETY:` comment explaining why the invariants hold, and recommends that reviewers treat unsafe code as roughly equivalent to C++ review — meaning two reviewers, one of whom must be on a designated readability list. This is the first widely-published corporate Rust guide to formalize the two-reviewer rule for unsafe code, and it maps cleanly onto Chromium's existing memory-safety review process.

The naming section is pragmatic and will mildly annoy some practitioners. Google follows the Rust API Guidelines' casing rules but adds a prohibition on single-letter type parameters outside of truly generic utility code — so `impl` is fine for a container, but a domain-specific generic should be `impl` not `impl`. The community has argued about this one for years and Google landed on the pedantic side.

One notable absence: the guide says relatively little about `async` conventions. Given Google's ongoing internal debate about Tokio vs their own runtimes, and the still-unresolved status of async traits in stable Rust as of late 2025, this is a tactical dodge. Expect that section to grow.

What this means for your stack

If you're running a Rust codebase larger than a few thousand lines, adopt Google's guide wholesale rather than writing your own. The delta between this document and the community defaults (`rustfmt` + the official API guidelines + `clippy::pedantic`) is small enough that the integration cost is near zero, and you get the compounding benefit of your style matching the style of every open-source Rust project your team will touch. Teams that fork style guides tend to drift, and drift kills the ergonomics of code review when engineers rotate.

The practical move: add `rustfmt.toml` with no overrides, enable `clippy::pedantic` with a documented list of allow-list exceptions, and copy Google's `// SAFETY:` comment requirement into your pre-submit hook. That's roughly 80% of the guide's actionable content, enforceable by tooling, and done in an afternoon. The remaining 20% — mostly naming and documentation prose style — is review-time guidance.

For shops considering Rust adoption, this release lowers the ambient political cost of the decision. One of the recurring objections to introducing Rust at mid-sized companies is "we don't have internal expertise to write a style guide." You now have one, written by a company with more production Rust than almost anyone else, free, and short enough to read in twenty minutes.

Looking ahead

The interesting question is what Google *didn't* publish: internal guidance on FFI boundaries with C++, procedural macro conventions, and the aforementioned `async` runtime story. Those are the hard problems in large-scale Rust, and the fact that Google is still working them out internally is a useful signal that even the biggest Rust shop in the industry hasn't fully solved them. Expect a v2 within eighteen months, and expect it to be the document the rest of us actually need.

Hacker News 371 pts 235 comments

Google's Rust Style Guide

→ read on Hacker News
japgolly · Hacker News

Apply #[non_exhaustive] to publicly-exposed enums seems like a crazy recommendation to me. So much of the power of enums is that when you add a new case the compiler will flag all pattern matches that you need to update, which is a good thing because you're forced to consider each case. Having

dathinab · Hacker News

Most important reading context:- this are rules created to be (kinda/mostly) uniformly applied across all projects at a Google Scale companyHaving used rust at work since roughly ~1.0 days I have come to a realization:- the style guides which work best for "blindly uniformly applied across

monocasa · Hacker News

Can anyone expand on the chromium specifc guidelines on super tiny crates, particularly no nesting of modules/source files?That feels like the ~2010 era of people saying that functions should be as small as possible. That lead me to reviewing a lot of code where every function was one or two li

epage · Hacker News

> Type names should be imported and used unqualifiedThis just pushes people to have redundant information in types (`IoError` instead of `io::Error`).Unless a type is widely recognized (like `HashMap`), I prefer to have them fully qualified so I have the contextual meaning for it. If I am working

TimTimTim1234 · Hacker News

Is this good? Do i give this to my agent or nah?

// share this

// get daily digest

Top 10 dev stories every morning at 8am UTC. AI-curated. Retro terminal HTML email.