Useful cargo commands
30 April 2018 · 3 minutes read · Commentscargo-xargorusttools
Some additional cargo commands exist to provide unprecedented level of support and extensibility to regular cargo. Here's a list of commands I use (will be updated over time, last update 2020-04-15):
cargo-edit - cargo add
, cargo rm
, cargo upgrade
Cargo.toml dependencies.
cargo-watch - add a cargo watch
command to monitor and rebuild source in case of changes.
cargo-bloat - find out what takes most of the space in your executable.
cargo-asm - see the assembly (with cargo asm
) or llvm-ir (with cargo llvm-ir
) generated for Rust code.
cargo-clippy - over 300 lints to make your Rust code tidy.
cargo-expand - show result of macro expansion and #[derive] expansion.
cargo-fmt - format Rust code, applies rustfmt to entire crate.
cargo-graph - create GraphViz DOT files and dependency graphs.
cargo-update - add cargo install-update
command to upgrade already installed binaries.
cargo-src - detailed rust source code browser with semantic details.
cargo-testify - show popup notifications about testing results.
cargo-tree - visualise crate dependencies as a tree.
cargo-vendor - vendor dependencies into a local directory.
cargo-web - automatically build and run web projects (use with parcel for amazing results).
cargo-fix - automatically apply fix-it suggestions from rustc and clippy to entire project. For better effect, run cargo clean
first, then cargo fix --clippy
.
cargo-release - for when you're ready to share your crate with the world, automates mundane release tasks - bumping versions, tagging repo, updating docs, etc.
version-sync - keep your version number in documentation and elsewhere in sync with version specified in Cargo.toml
cargo-generate - generate cargo project from a given template.
cargo-geiger - count number of unsafe
operations in crate and its dependencies.
cargo-xbuild - a replacement for xargo (which is now in maintenance mode).
cargo-make - a decent replacement for make.
just - another (more make-like) make replacement, modern and robust.