2018-10-07 12:15:27 +00:00
|
|
|
# Cargo is the Rust package manager
|
|
|
|
# Cargo downloads your Rust project's dependencies,
|
|
|
|
# compiles your project, makes packages, and upload them to crates.io
|
2019-08-06 13:28:53 +00:00
|
|
|
# See also: https://doc.rust-lang.org/cargo/
|
2018-10-07 12:15:27 +00:00
|
|
|
|
2019-08-06 13:28:53 +00:00
|
|
|
# To start a new project
|
2018-10-07 12:15:27 +00:00
|
|
|
cargo new hello_world --bin # program
|
|
|
|
cargo new hello_world --lib # library
|
|
|
|
|
2019-08-06 13:28:53 +00:00
|
|
|
# Build a project without optimizations (in debug mode)
|
2018-10-07 12:15:27 +00:00
|
|
|
cargo build
|
|
|
|
|
|
|
|
# Build a project with optimizations turned on
|
|
|
|
cargo build --release
|
|
|
|
|
2019-08-06 13:28:53 +00:00
|
|
|
# Build and run (without optimizations) a package with Cargo
|
|
|
|
cargo run
|
|
|
|
|
2018-10-07 12:15:27 +00:00
|
|
|
# Updates dependencies in Cargo.lock
|
|
|
|
cargo update # update all
|
2019-08-06 13:28:53 +00:00
|
|
|
cargo update -p rand # updates just “rand” crate
|
2018-10-07 12:15:27 +00:00
|
|
|
|
|
|
|
# run the project tests (from src/ and tests/)
|
|
|
|
cargo test
|
|
|
|
|
2019-08-06 13:28:53 +00:00
|
|
|
# Clean all output build files and targets
|
|
|
|
cargo clean
|
|
|
|
|
2018-10-07 12:15:27 +00:00
|
|
|
# search for a package
|
|
|
|
cargo search
|