Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Cargo / Dependencies section #1287

Merged
merged 1 commit into from
Oct 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/cargo/deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand All @@ -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.

Expand Down