cargo
cargo
comes preinstalled with rustup.
Usage
-
cargo new
→ either creates a new folder with aCargo.toml
, asrc/main.rs
and initializes a git repo (by default). -
cargo init
in a preexisting folder. -
cargo new --vcs
→ to change the version control tool. -
cargo build
to compile and create an executable.--debug
(which is by default) compiles faster then--release
. -
cargo run
to compile and immediatly run the resulting executable, without making an executable. Faster thenbuild
-
cargo check
to check the code without making an executable nor running the program. Serves to check if the program still compiles. It is faster thenrun
andbuild
. -
cargo run/build --offline
to use local offline dep instead of online. -
cargo add
to add dependencies to the project (and automatically in theCargo.toml
).