Rust Formatter
Format Rust code with rustfmt-style 4-space indentation. Handles fn, impl, struct, enum, match arms, and trait definitions.
What is rustfmt?
rustfmt is Rust's official code formatting tool, installed with Rustup and run via cargo fmt. Like Go's gofmt, rustfmt enforces a single canonical style for all Rust code: 4-space indentation, K&R-style braces, and specific rules for match arms, generics, and trait bounds. Following rustfmt conventions is essential for contributing to Rust open-source projects.
Frequently Asked Questions
&T or mutable references &mut T), with the compiler enforcing that mutable borrows are exclusive. This eliminates data races and use-after-free bugs at compile time.String is an owned, heap-allocated, mutable string. &str is a string slice — a borrowed reference to a sequence of UTF-8 bytes, often a view into a String or a string literal. Use &str for function parameters (more flexible), and String when you need to own and mutate the string.Option represents a value that may or may not exist: Some(value) or None. Rust has no null — any type that could be absent must be wrapped in Option, forcing you to handle the absence case explicitly. This eliminates null pointer dereferences, one of the most common sources of bugs in other languages.Enjoying this tool?
Every tool here is free, forever — no signup, no paywall. If this one just saved you real time, a small tip keeps them free and ad-light.
☕ Support This Tool →Need something built, not just formatted?
This toolbox is free. If your business needs custom software, AI integration, or a system built around this kind of tooling, that's what I do for a living.