2019-08-06 13:28:53 +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
|
|
|
|
# See also: https://doc.rust-lang.org/cargo/
|
2019-08-02 12:46:07 +00:00
|
|
|
|
2019-08-06 13:28:53 +00:00
|
|
|
# To start a new project
|
|
|
|
cargo new hello_world --bin # program
|
|
|
|
cargo new hello_world --lib # library
|
2019-08-02 12:46:07 +00:00
|
|
|
|
2019-08-06 13:28:53 +00:00
|
|
|
# Build a project without optimizations (in debug mode)
|
2019-08-02 12:46:07 +00:00
|
|
|
cargo build
|
|
|
|
|
2019-08-06 13:28:53 +00:00
|
|
|
# Build a project with optimizations turned on
|
|
|
|
cargo build --release
|
|
|
|
|
|
|
|
# Build and run (without optimizations) a package with Cargo
|
2019-08-02 12:46:07 +00:00
|
|
|
cargo run
|
|
|
|
|
2019-08-06 13:28:53 +00:00
|
|
|
# Updates dependencies in Cargo.lock
|
|
|
|
cargo update # update all
|
|
|
|
cargo update -p rand # updates just “rand” crate
|
|
|
|
|
|
|
|
# run the project tests (from src/ and tests/)
|
|
|
|
cargo test
|
2019-08-02 12:46:07 +00:00
|
|
|
|
2019-08-06 13:28:53 +00:00
|
|
|
# Clean all output build files and targets
|
2019-08-02 12:46:07 +00:00
|
|
|
cargo clean
|
|
|
|
|
2019-08-06 13:28:53 +00:00
|
|
|
# search for a package
|
|
|
|
cargo search
|