From 11b26c87cfafafc922c48577a94b449dfd4f406b Mon Sep 17 00:00:00 2001 From: Marcus Stollsteimer Date: Mon, 28 Oct 2019 09:11:04 +0100 Subject: [PATCH] Improve Cargo / Dependencies section --- src/cargo/deps.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cargo/deps.md b/src/cargo/deps.md index 21db4c2a65..7403a2ae76 100644 --- a/src/cargo/deps.md +++ b/src/cargo/deps.md @@ -15,10 +15,10 @@ cargo new foo cargo new --lib foo ``` -For the rest of this chapter, I will assume we are making a binary, rather than +For the rest of this chapter, let's assume we are making a binary, rather than a library, but all of the concepts are the same. -After the above commands, you should see something like this: +After the above commands, you should see a file hierarchy like this: ```txt foo @@ -40,7 +40,7 @@ authors = ["mark"] [dependencies] ``` -The `name` field under `package` determines the name of the project. This is +The `name` field under `[package]` determines the name of the project. This is used by `crates.io` if you publish the crate (more later). It is also the name of the output binary when you compile. @@ -49,14 +49,14 @@ Versioning](http://semver.org/). The `authors` field is a list of authors used when publishing the crate. -The `dependencies` section lets you add a dependency for your project. +The `[dependencies]` section lets you add dependencies for your project. -For example, suppose that I want my program to have a great CLI. You can find +For example, suppose that we want our program to have a great CLI. You can find lots of great packages on [crates.io](https://crates.io) (the official Rust package registry). One popular choice is [clap](https://crates.io/crates/clap). As of this writing, the most recent published version of `clap` is `2.27.1`. To add a dependency to our program, we can simply add the following to our -`Cargo.toml` under `dependencies`: `clap = "2.27.1"`. And of course, `extern +`Cargo.toml` under `[dependencies]`: `clap = "2.27.1"`. And of course, `extern crate clap` in `main.rs`, just like normal. And that's it! You can start using `clap` in your program.