Introduction - The Cargo Book
curl <https://sh.rustup.rs> -sSf | sh
rustup component add rust-analyzer rust-src
# Create a new cargo package.
cargo new <path>
cargo new --lib <path>
# Compile the current package.
cargo build
cargo build --examples
# Run a binary or example of the local package.
cargo run
cargo run --example <NAME>
# Run the tests.
cargo test
# Run the benchmarks.
cargo bench
# Build this package's and its dependencies' documentation.
cargo doc
# Remove artifacts that cargo has generated in the past.
cargo clean
# Search packages in crates.io
cargo search [query]
# Windows 32bit
rustup install stable-i686-pc-windows-msvc
rustup default stable-i686-pc-windows-msvc
# Windows 64bit
rustup default stable-x86_64-pc-windows-msvc
Example
Cargo.toml
[dependencies]
time = "^0.1.12"
hello_utils = { path = "hello_utils" }
hello_utils = { path = "hello_utils", version = "0.1.0" }