🔧 Rustfmt is an official tool for formatting Rust code according to the Rust style guide. It automatically adjusts code structure, spacing, and syntax to ensure consistency across projects.
Key Features
- 🚀 Automated Formatting: Fixes indentation, spacing, and line breaks with a single command
- 📌 Customizable Rules: Adjust formatting preferences via
config
files - 📂 Project-Wide Application: Formats entire codebases recursively
- 🔄 Reversible Changes: Use
--check
to preview modifications without applying
How to Use
- Install via
cargo install rustfmt
- Run with
cargo fmt
in your project directory - Configure rules at
/en/configuring_rustfmt
- Use
--write-mode=diff
to see changes before applying
Tips
- 🧠 Always run
cargo fmt
before code reviews - ⚠️ Use
--check
to verify formatting without modifying files - 📚 Learn more about Rustfmt options
For advanced usage, explore our Rustfmt documentation to discover how to integrate it with editors or CI pipelines.