🔧 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

  1. Install via cargo install rustfmt
  2. Run with cargo fmt in your project directory
  3. Configure rules at /en/configuring_rustfmt
  4. 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
code_formatting

For advanced usage, explore our Rustfmt documentation to discover how to integrate it with editors or CI pipelines.