AI NewsProductivityAnnouncement

Google publishes its internal Rust style guide for the first time

Google exported its internal Rust style guide to the public google/styleguide repository, giving outside Rust teams the first look at the rules Google writes its own Rust code against.

AI News

Editorial2 min read

LinkedInX
Rust programming language logo on a dark background

Why it mattersA Rust team now has a free second opinion on the questions a style guide usually has to settle in a long thread, from a company that writes a lot of Rust.

A Rust team arguing over whether to use Arc or borrow a value, or whether a function should take impl Into<String>, now has a short answer from Google. The company exported its internal Rust style guide to the public google/styleguide repository on 21 October 2026, two commits from an automated bridge Google uses to open-source its internal guides.

The document is 70-plus sections. It covers code organisation, formatting, ownership and borrowing, iterators versus owned collections, errors, traits, generics, naming, concurrency, macros, documentation, and specific guidance on common standard-library traits. Each section is one page in a single HTML file, with the full table of contents at the top. Google's styleguide repository already carries guides for C++, Python, Go, Java, JavaScript, TypeScript, Shell and others. Rust is the newest.

What the guide actually says

Google's advice is often strong. The document says to avoid Rc and Arc, prefer borrows over deep copies, and reach for enum over bool in a function signature. It says not to use async / .await and not to start new threads through the standard library in Chrome Rust code, with the Fuchsia project using its own fuchsia_sync::Mutex. It says to prefer expect over unwrap, to avoid iterator combinator chains when direct iteration would be clearer, and to apply #[non_exhaustive] to publicly-exposed enums and public structs with public fields.

The sections marked [chrome] or [Fuchsia] are specific to one of Google's codebases, so an outside team should read them as "this is the rule in that project", not as general advice. The rest is written for Rust at Google as a whole and translates straight to any codebase.

Who gains from reading it

A team that has already written a style guide can run its own rules past Google's and see which ones Google agreed with and which ones Google went the other way on. A team without one can start from this file instead of a blank page, and a team arguing about Rc can point at the Google guide to end the thread. The guide is published under the same Apache 2.0 licence as the rest of google/styleguide, so a company is free to copy sections verbatim into its own repository.

The guide does not cite benchmarks or defect data behind its choices, and it does not say which versions of Rust the rules were written against. A team reading it should still check each rule against its own compiler version and its own crate ecosystem.

Source

Google Rust Style Guide. Discussion on Hacker News.

SourceGoogle

This item was written by an AI system from the linked source. Reveneau is responsible for what it publishes.

Share
LinkedInX
Start a project