Index

Table of contents

rust cli

cargo

create new empty project
cargo new [name]
don't create git dir
cargo new [name] --vcs=none
build and run
cargo run
choose a specific main method
cargo run --bin [main]
create development build
cargo build
create new release
cargo build --release
clean build dir
cargo clean
find crates
cargo search [query]
show cargo version
cargo -V
specify a different directory for cargo (.bashrc for permanent solution)
export CARGO_TARGET_DIR=/tmp/cargo

cargo metadata

name    = name of program, used to create binary
version = version of your project
authors = array containing author names
edition = major edition or rust to build project
defining multiple binaries for one project
[[bin]]
name = "client"
path = "src/client.rs"

[[bin]]
name = "server"
path = "src/server.rs"
defining a dependency
[dependencies]
[crate] = "[version]"
example
regex = "*"
version specification
^1.2.3     =    >=1.2.3, <2.0.0
^1.2       =    >=1.2.0, <2.0.0
^1         =    >=1.0.0, <2.0.0
^0.2.3     =    >=0.2.3, <0.3.0
^0.2       =    >=0.2.0, <0.3.0
^0.0.3     =    >=0.0.3, <0.0.4
^0.0       =    >=0.0.0, <0.1.0
^0         =    >=0.0.0, <1.0.0

~1.2.3     =    >=1.2.3, <1.3.0
~1.2       =    >=1.2.0, <1.3.0
~1         =    >=1.0.0, <2.0.0

*          =    >=0.0.0
1.*        =    >=1.0.0, <2.0.0
1.2.*      =    >=1.2.0, <1.3.0
or explicitly specify the version
>= 1.2.0
> 1
< 2
= 1.2.3
>= 1.2, < 1.5

cargo documentation

https://doc.rust-lang.org/stable/cargo/
https://doc.rust-lang.org/cargo/index.html