Like most Rust projects,
Firecracker uses
cargo fmt
(namely rustfmt
) to format Rust code.
This rule is applied bu executing the pre-commit
shell script, and enforced in
their CI.
This script lints every staged file, as of .rs
s, it apply cargo fmt
on them.
The command directly formats that file instead of produce differences
before/after format.
rustfmt
(invoked by cargo fmt
command) could be installed with:
rustup component add rustfmt
And we can then use it with command:
cargo fmt
Sometimes we need unstable options of rustfmt
, e.g. group_imports
and the
like. These options are not available in stable channel, thus we need to install
nightly channel:
rustup component add rustfmt --toolchain nightly
Then we can use nightly rustfmt
with:
cargo +nightly fmt