Skip to content

rustfmt.toml

Put this file at your repository root and run cargo +nightly fmt. Stable rustfmt applies max_width and skips the three nightly-only options with a warning.

Download rustfmt.toml

rustfmt.toml
# Formatting options named by the Google Rust style guide.
# https://google.github.io/styleguide/rustguide.html#use-the-appropriate-formatting-tool
max_width = 100
# The options below are unstable. Stable rustfmt prints a warning and skips them,
# so run `cargo +nightly fmt` to apply the full configuration.
hex_literal_case = "Lower"
format_macro_matchers = true
# One `use` statement per module, with no nested `::` inside `{..}`.
# https://google.github.io/styleguide/rustguide.html#a-use-statement-should-import-items-from-one-module
imports_granularity = "Module"

Source: rustfmt.toml on GitHub. New to the kit? Start with the quick start.

Unofficial community project, not affiliated with or endorsed by Google. TheGoogle Rust Style Guide is published by Google under CC-BY 3.0. This kit is Apache-2.0.