Skip to content

Commit 91d00c6

Browse files
committed
content: Add installation guide of rustfmt
Aside from stable `rustfmt` guide, add nightly `rustfmt` installation and use guide to format Rust code with unstable options. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
1 parent 0dbd331 commit 91d00c6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/repo-management/firecracker/rustfmt.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,33 @@ their CI.
1212
This script lints every staged file, as of `.rs`s, it apply `cargo fmt` on them.
1313
The command directly formats that file instead of produce differences
1414
before/after format.
15+
16+
## Install rustfmt
17+
18+
`rustfmt` (invoked by `cargo fmt` command) could be installed with:
19+
20+
```sh
21+
rustup component add rustfmt
22+
```
23+
24+
And we can then use it with command:
25+
26+
```sh
27+
cargo fmt
28+
```
29+
30+
### Nightly Toolchain
31+
32+
Sometimes we need unstable options of `rustfmt`, e.g. `group_imports` and the
33+
like. These options are not available in stable channel, thus we need to install
34+
nightly channel:
35+
36+
```sh
37+
rustup component add rustfmt --toolchain nightly
38+
```
39+
40+
Then we can use nightly `rustfmt` with:
41+
42+
```sh
43+
cargo +nightly fmt
44+
```

0 commit comments

Comments
 (0)