January 2019
Intermediate to advanced
520 pages
14h 32m
English
Let's create a new project with all the necessary dependencies. We will create a binary utility for managing users in a database. Create a new binary crate:
cargo new --bin users
Next, add the dependencies:
cargo add clap postgres
But wait! Cargo doesn't contain an add command. I've installed cargo-edit tool for managing dependencies. You can do this with the following command:
cargo install cargo-edit
The preceding command installs the cargo-edit tool. If you don't install it, your local cargo won't have an add command. Install the cargo-edit tool and add the postgres dependency. You can also add dependencies manually by editing the Cargo.toml file, but as we are going to create more complex projects, the cargo-edit
Read now
Unlock full access