Skip to content

Commit

Permalink
Merge pull request #1287 from stomar/cargo-dependencies
Browse files Browse the repository at this point in the history
Improve Cargo / Dependencies section
  • Loading branch information
marioidival authored Oct 29, 2019
2 parents bb1ecf1 + 11b26c8 commit eecb53c
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit eecb53c

Please sign in to comment.