Cargo
Installation
It comes with the Rust installation. To check if it’s installed, run:
cargo --version
cargo 1.81.0 (2dbb1af80 2024-08-20)
Help
cargo --help
Rust's package manager
Usage: cargo [+toolchain] [OPTIONS] [COMMAND]
cargo [+toolchain] [OPTIONS] -Zscript [ARGS]...
Create
Creates a new project.
cargo new <project-name>
cargo new foo-bar
Creating binary (application) `foo-bar` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Build
Builds the project’s executable.
cargo build
Compiling foo-bar v0.1.0 (/Users/damazio/git/carlosdmz/foo-bar)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.16s
./target/debug/foo-bar
Hello, world!