File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,25 @@ read data from stdin. Alternatively, you can use `cargo fmt` to format all
102102binary and library targets of your crate.
103103
104104You can run ` rustfmt --help ` for information about available arguments.
105+ The easiest way to run rustfmt against a project is with ` cargo fmt ` . ` cargo fmt ` works on both
106+ single-crate projects and [ cargo workspaces] ( https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html ) .
107+ Please see ` cargo fmt --help ` for usage information.
108+
109+ You can specify the path to your own ` rustfmt ` binary for cargo to use by setting the` RUSTFMT `
110+ environment variable. This was added in v1.4.22, so you must have this version or newer to leverage this feature (` cargo fmt --version ` )
111+
112+ ### Running ` rustfmt ` directly
113+
114+ To format individual files or arbitrary codes from stdin, the ` rustfmt ` binary should be used. Some
115+ examples follow:
116+
117+ - ` rustfmt lib.rs main.rs ` will format "lib.rs" and "main.rs" in place
118+ - ` rustfmt ` will read a code from stdin and write formatting to stdout
119+ - ` echo "fn main() {}" | rustfmt ` would emit "fn main() {}".
120+
121+ For more information, including arguments and emit options, see ` rustfmt --help ` .
122+
123+ ### Verifying code is formatted
105124
106125When running with ` --check ` , Rustfmt will exit with ` 0 ` if Rustfmt would not
107126make any formatting changes to the input, and ` 1 ` if Rustfmt would make changes.
You can’t perform that action at this time.
0 commit comments