Home

rustfmt

rustfmt is a code formatter for Rust. It automatically formats Rust source files to conform to the standard Rust style, ensuring consistent indentation, line breaks, and spacing. By applying the same formatting rules across projects, it reduces diffs and code-review friction. rustfmt is an official part of the Rust project and is distributed with the Rust toolchain.

Usage: It is distributed as a tool component and can be installed via rustup; after installation you

Configuration: The formatter can be customized using a rustfmt.toml configuration file placed in the project root.

Integration and ecosystem: rustfmt is widely integrated into Rust tooling and editors, such as IDEs and editor

Development: rustfmt is maintained by the Rust community as an open-source project. It is designed to be

format
code
with
cargo
fmt
for
a
crate
or
workspace,
or
with
rustfmt
on
individual
files.
The
common
workflow
is
to
run
cargo
fmt
before
committing
or
in
continuous
integration.
To
check
formatting
without
changing
files,
use
cargo
fmt
--
--check
(or
rustfmt
--check
for
a
single
file).
Options
may
include
max_width
to
control
line
length,
tab_spaces
to
influence
tab
width,
and
use_small_heuristics
to
tune
formatting
decisions.
The
configuration
can
be
overridden
on
the
command
line
as
well.
plugins,
and
is
commonly
run
as
part
of
code
style
checks
in
continuous
integration.
It
formats
code
consistently
across
crates,
regardless
of
author
or
project
conventions.
deterministic
and
reproducible,
given
the
same
input
and
configuration,
and
continues
to
evolve
with
the
Rust
language
and
its
formatting
guidelines.