Tested tool guide
Tested browser tools
Checked August 16, 2026
What Rust Formatter (rustfmt) does, with a checked example
rustfmt is the official Rust formatter, installed with the Rust toolchain. It is a command-line program that runs locally: it parses a .rs file on your machine and re-emits it with the spacing, indentation, and line breaks defined by the Rust Style Guide - the code is never uploaded anywhere. Run rustfmt file.rs for one file, cargo fmt for a whole crate. The surprise most users hit: it refuses code it cannot parse, so a syntax error or an edition mismatch means the file is left untouched, and it only reflows layout - it never removes unused imports, renames anything, or rewrites comments.
Worked example
A concrete input and expected output from the current implementation.
Input
fn main(){let x:Vec<u32>=vec![1,2,3];println!("{:?}",x);} ->
Expected output
fn main() {
let x: Vec<u32> = vec![1, 2, 3];
println!("{:?}", x);
} rustfmt put a space before the opening brace, moved the body to its own line at four-space indentation, and normalized spacing: around the =, after the type colon, and after commas inside the vec! and println! arguments. Running the output through rustfmt again returns the same text unchanged.