Skip to content

Commit fc9bc77

Browse files
committed
1 parent 6afa669 commit fc9bc77

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/doc/trpl/guessing-game.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -410,24 +410,29 @@ $ cargo build
410410
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
411411
```
412412

413-
So, we told Cargo we wanted any version of `rand`, and so it fetched the
414-
latest version at the time this was written, `v0.3.8`. But what happens
415-
when next week, version `v0.4.0` comes out, which changes something with
416-
`rand`, and it includes a breaking change? After all, a `v0.y.z` version
417-
in SemVer can change every release.
413+
So, we told Cargo we wanted any version of `rand`, and so it fetched the latest
414+
version at the time this was written, `v0.3.8`. But what happens when next
415+
week, version `v0.3.9` comes out, with an important bugfix? While getting
416+
bugfixes is important, what if `0.3.9` contains a regression that breaks our
417+
code?
418418

419419
The answer to this problem is the `Cargo.lock` file you’ll now find in your
420420
project directory. When you build your project for the first time, Cargo
421421
figures out all of the versions that fit your criteria, and then writes them
422422
to the `Cargo.lock` file. When you build your project in the future, Cargo
423423
will see that the `Cargo.lock` file exists, and then use that specific version
424424
rather than do all the work of figuring out versions again. This lets you
425-
have a repeatable build automatically.
425+
have a repeatable build automatically. In other words, we’ll stay at `0.3.8`
426+
until we explicitly upgrade, and so will anyone who we share our code with,
427+
thanks to the lock file.
426428

427-
What about when we _do_ want to use `v0.4.0`? Cargo has another command,
429+
What about when we _do_ want to use `v0.3.9`? Cargo has another command,
428430
`update`, which says ‘ignore the lock, figure out all the latest versions that
429431
fit what we’ve specified. If that works, write those versions out to the lock
430-
file’.
432+
file’. But, by default, Cargo will only look for versions larger than `0.3.0`
433+
and smaller than `0.4.0`. If we want to move to `0.4.x`, we’d have to update
434+
the `Cargo.toml` directly. When we do, the next time we `cargo build`, Cargo
435+
will update the index and re-evaluate our `rand` requirements.
431436

432437
There’s a lot more to say about [Cargo][doccargo] and [its
433438
ecosystem][doccratesio], but for now, that’s all we need to know. Cargo makes

0 commit comments

Comments
 (0)