cargo fmt
built-in 78.2% Savings
18 Commands
1.4K Tokens saved
3 Tests
Install
Safety checks passed
Filter definition
command = "cargo fmt"
# Auto-fixable: formatting diffs detected by "Diff in " header from rustfmt.
# Shows file list extracted via template pipe from raw output.
match_output = [
{ contains = "Diff in ", output = "✗ formatting issues — run `cargo fmt` to fix:\n{output | lines | keep: \"^Diff in \" | join: \"\\n\"}" },
]
[on_success]
output = "✓ cargo fmt: ok"
[on_failure]
# Non-auto-fixable: syntax errors (no "Diff in" in output)
tail = 20
Examples
check failure shows file list and fix hint
~138 tokens → ~37 tokens
(73% saved)
Raw output
Diff in /home/user/project/src/main.rs at line 1:
--- /home/user/project/src/main.rs 2024-01-01 00:00:00.000000000 +0000
+++ /home/user/project/src/main.rs 2024-01-01 00:00:00.000000000 +0000
@@ -1,5 +1,5 @@
-fn main() {
+fn main() {
println!("hello");
}
Diff in /home/user/project/src/lib.rs at line 3:
--- /home/user/project/src/lib.rs 2024-01-01 00:00:00.000000000 +0000
+++ /home/user/project/src/lib.rs 2024-01-01 00:00:00.000000000 +0000
@@ -3,5 +3,5 @@
-pub fn add( a: i32,b: i32) -> i32 {
+pub fn add(a: i32, b: i32) -> i32 {
a + b
} Filtered output
✗ formatting issues — run `cargo fmt` to fix: Diff in /home/user/project/src/main.rs at line 1: Diff in /home/user/project/src/lib.rs at line 3:
success produces ok message
~0 tokens → ~4 tokens
Raw output
Filtered output
✓ cargo fmt: ok
syntax error shows raw error output
~49 tokens → ~49 tokens
Raw output
error: failed to parse src/broken.rs: expected expression, found `}`
--> src/broken.rs:5:1
|
5 | fn broken( {
| ^^^^^^^^^^^^ expected one of `)`, `,`, `_`, `mut`, `ref`, pattern, or identifier Filtered output
error: failed to parse src/broken.rs: expected expression, found `}`
--> src/broken.rs:5:1
|
5 | fn broken( {
| ^^^^^^^^^^^^ expected one of `)`, `,`, `_`, `mut`, `ref`, pattern, or identifier Warning: Community filters are third-party code. Review the filter definition above before installing it in production environments.Browse all filters