Clear up discussion of not needing to download/rebuild deps

This commit is contained in:
Carol (Nichols || Goulding) 2016-09-27 11:27:23 -04:00
parent 091e1bc674
commit d72385839c

View File

@ -405,26 +405,24 @@ After updating the registry, Cargo checks our `[dependencies]` and downloads
any we dont have yet. In this case, while we only listed `rand` as a any we dont have yet. In this case, while we only listed `rand` as a
dependency, weve also grabbed a copy of `libc`, because `rand` depends on dependency, weve 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, well 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, well only see one
Thats 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. Theres
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,
well 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