Merge pull request #270 from rust-lang/clear-up-ch2

Clear up discussion of not needing to download/rebuild deps
This commit is contained in:
Carol (Nichols || Goulding)
2016-10-02 14:07:37 -04:00
committed by GitHub
+11 -13
View File
@@ -405,26 +405,24 @@ After updating the registry, Cargo checks our `[dependencies]` and downloads
any we don’t have yet. In this case, while we only listed `rand` as a any we don’t have yet. In this case, while we only listed `rand` as a
dependency, we’ve also grabbed a copy of `libc`, because `rand` depends on dependency, we’ve also grabbed a copy of `libc`, because `rand` depends on
`libc` to work. After downloading them, Rust compiles them and then compiles `libc` to work. After downloading them, Rust compiles them and then compiles
our project. our project with our dependencies available.
If we run `cargo build` again, we’ll get different output: If we immediately run `cargo build` again without making any changes, we won't
get any output. Cargo knows it has already downloaded and compiled our
```bash dependencies, and we haven't changed anything about them in our `Cargo.toml`
$ cargo build file. Cargo also knows that we haven't changed anything about our code, so it
``` doesn't recompile that either. With nothing to do, it simply exits. If we open
up `src/main.rs`, make a trivial change, then save it again, we’ll only see one
That’s right, no output! Cargo knows that our project has been built, that line:
all of its dependencies are built, and that no changes have been made. There’s
no reason to do all that stuff again. With nothing to do, it simply
exits. If we open up `src/main.rs`, make a trivial change, then save it again,
we’ll only see one line:
```bash ```bash
$ cargo build $ cargo build
Compiling guessing_game v0.1.0 (file:///projects/guessing_game) Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
``` ```
This just updates the build with your tiny change to the `main.rs` file. This just updates the build with your tiny change to the `main.rs` file. Our
dependencies haven't changed, so Cargo knows it can reuse what it has already
downloaded and compiled for those. It just rebuilds our part of the code.
#### The Cargo.lock File that Ensures Reproducible Builds #### The Cargo.lock File that Ensures Reproducible Builds