@@ -371,13 +371,15 @@ Now, without changing any of our code, let’s build our project:
371
371
``` bash
372
372
$ cargo build
373
373
Updating registry ` https://github.com/rust-lang/crates.io-index`
374
- Downloading rand v0.3.0
374
+ Downloading rand v0.3.8
375
375
Downloading libc v0.1.6
376
376
Compiling libc v0.1.6
377
- Compiling rand v0.3.0
377
+ Compiling rand v0.3.8
378
378
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
379
379
```
380
380
381
+ (You may see different versions, of course.)
382
+
381
383
Lots of new output! Now that we have an external dependency, Cargo fetches the
382
384
latest versions of everything from the registry, which is a copy of data from
383
385
[ Crates.io] [ cratesio ] . Crates.io is where people in the Rust ecosystem
@@ -407,19 +409,19 @@ $ cargo build
407
409
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
408
410
```
409
411
410
- Let's pretend that we told Cargo we wanted the latest version of ` rand ` (using ` * ` )
411
- for a bit. It would have fetched ` v0.3.8 ` (at the time this was written).
412
- But what happens when next week, version ` v0.3.9 ` comes out, with an important
413
- bugfix? While getting bugfixes is important, what if ` 0.3.9 ` contains a regression
414
- that breaks our code?
412
+ So, we told Cargo we wanted any ` 0.3.x ` version of ` rand ` , and so it fetched the latest
413
+ version at the time this was written, ` v0.3.8 ` . But what happens when next
414
+ week, version ` v0.3.9 ` comes out, with an important bugfix? While getting
415
+ bugfixes is important, what if ` 0.3.9 ` contains a regression that breaks our
416
+ code?
415
417
416
418
The answer to this problem is the ` Cargo.lock ` file you’ll now find in your
417
419
project directory. When you build your project for the first time, Cargo
418
420
figures out all of the versions that fit your criteria, and then writes them
419
421
to the ` Cargo.lock ` file. When you build your project in the future, Cargo
420
422
will see that the ` Cargo.lock ` file exists, and then use that specific version
421
423
rather than do all the work of figuring out versions again. This lets you
422
- have a repeatable build automatically. In other words, we’ll stay at ` 0.3.0 `
424
+ have a repeatable build automatically. In other words, we’ll stay at ` 0.3.8 `
423
425
until we explicitly upgrade, and so will anyone who we share our code with,
424
426
thanks to the lock file.
425
427
@@ -439,8 +441,7 @@ projects which are assembled out of a number of sub-packages.
439
441
[ doccargo ] : http://doc.crates.io
440
442
[ doccratesio ] : http://doc.crates.io/crates-io.html
441
443
442
- Let’s get on to actually _ using_ ` rand ` . Keep the version as ` 0.3.0 ` for this
443
- project. Here’s our next step:
444
+ Let’s get on to actually _ using_ ` rand ` . Here’s our next step:
444
445
445
446
``` rust,ignore
446
447
extern crate rand;
0 commit comments