install a package
cargo install name
update a package
cargo update name
or leave out name to update all.
create project
cargo new name
build and run
cargo run
cargo build
# or with optimizations:
cargo build --release
# or simply check that it could compile
# often faster than actually compiling:
cargo check
test
cargo test
show output
By default rust will hide the stdout from your tests. You can show it with:
cargo test -- --show-output
consecutively
Tests are normally each run in their own thread. If you would like to instead run all the tests consecutively:
cargo test -- --test-threads=1
a single test
It's actually a pattern so you can use this to match any test which contains the name "add":
cargo test add
documentation
Build and open documentation provided by local dependencies.
cargo doc --open
show result of macro and #[derive] expansion
This can be done with the cargo-expand tool:
cargo install cargo-expand
cargo expand