]> git.lizzy.rs Git - rust.git/blob - README.md
Use the log/env_logger crates from crates.io
[rust.git] / README.md
1 # rustfmt
2
3 A tool for formatting Rust code according to style guidelines.
4
5 ## Gotchas
6 * For things you do not want rustfmt to mangle, use
7 ```rust
8  #[rustfmt_skip]
9  ```
10 * When you run rustfmt use a file called rustfmt.toml to override the default settings of rustfmt.
11 * We create a functioning executable called rustfmt in the target directory
12
13 ## How to build and test
14 You'll need a pretty up to date version of the **nightly** version of Rust.
15
16 `cargo build` to build.
17
18 `cargo test` to run all tests.
19
20 `cargo run -- filename` to run on a file, if the file includes out of line modules,
21 then we reformat those too. So to run on a whole module or crate, you just need
22 to run on the top file.
23
24 You'll probably want to specify the write mode. Currently, there are the replace,
25 overwrite and display mode. The replace mode is the default and overwrites the
26 original files after renaming them. In overwrite mode, rustfmt does not backup
27 the source files. To print the output to stdout, use the display mode. The write
28 mode can be set by passing the `--write-mode` flag on the command line.
29
30 `cargo run -- filename --write-mode=display` prints the output of rustfmt to the
31 screen, for example.