Rust
The Rust compiler is pretty pedantic by default, however, we have a few recommendations:
- Change the default check command in VSCode (instead of check use
clippy). - 4 spaces for tabs.
- Macros are cool but don’t overuse them.
- Use rustfmt:
cargo fmt.
Recommended tools
Bacon
Get bacon, open it in another terminal window, leave it running while you edit. It will save you recompiling constantly to get the verbose compiler output.
It also has handy features:
a- to check all.c- to clippy all.t- to run tests.n- to run tests viacargo-nextest.
You can also make it run pedantic checks with bacon pedantic.
Audit
cargo install cargo-audit (or use cargo-binstall).
You can then run cargo audit to audit your dependencies for security vulnerabilities.
Flamegraph
cargo install cargo-flamegraph (or use cargo-binstall).
You can then use CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph [-- args-for-your-project] to generate a Flamegraph for profiling and optimising your project.
Machete
cargo install cargo-machete (or use cargo-binstall).
You can then use cargo machete to remove unused dependencies.