Skip to content

Commit 24f8cde

Browse files
committed
---
yaml --- r: 208147 b: refs/heads/snap-stage3 c: 0bc6fe5 h: refs/heads/master i: 208145: 5677b85 208143: 5b9368b v: v3
1 parent 4d65ae8 commit 24f8cde

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 7150d3cd9e011367f3c6fb6ff8d1e4c0f7a26e95
4+
refs/heads/snap-stage3: 0bc6fe5ea0b4e4fcbc98145855a1c416d08dfab0
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/doc/trpl/guessing-game.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -352,17 +352,16 @@ add these few lines at the bottom:
352352
```toml
353353
[dependencies]
354354

355-
rand="*"
355+
rand="0.3.0"
356356
```
357357

358358
The `[dependencies]` section of `Cargo.toml` is like the `[package]` section:
359359
everything that follows it is part of it, until the next section starts.
360360
Cargo uses the dependencies section to know what dependencies on external
361-
crates you have, and what versions you require. In this case, we’ve used `*`,
362-
which means that we’ll use the latest version of `rand`. Cargo understands
363-
[Semantic Versioning][semver], which is a standard for writing version
364-
numbers. If we wanted a specific version or range of versions, we could be
365-
more specific here. [Cargo’s documentation][cargodoc] contains more details.
361+
crates you have, and what versions you require. In this case, we’ve used version `0.3.0`.
362+
Cargo understands [Semantic Versioning][semver], which is a standard for writing version
363+
numbers. If we wanted to use the latest version we could use `*` or we could use a range
364+
of versions. [Cargo’s documentation][cargodoc] contains more details.
366365

367366
[semver]: http://semver.org
368367
[cargodoc]: http://doc.crates.io/crates-io.html
@@ -372,15 +371,13 @@ Now, without changing any of our code, let’s build our project:
372371
```bash
373372
$ cargo build
374373
Updating registry `https://github.com/rust-lang/crates.io-index`
375-
Downloading rand v0.3.8
374+
Downloading rand v0.3.0
376375
Downloading libc v0.1.6
377376
Compiling libc v0.1.6
378-
Compiling rand v0.3.8
377+
Compiling rand v0.3.0
379378
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
380379
```
381380

382-
(You may see different versions, of course.)
383-
384381
Lots of new output! Now that we have an external dependency, Cargo fetches the
385382
latest versions of everything from the registry, which is a copy of data from
386383
[Crates.io][cratesio]. Crates.io is where people in the Rust ecosystem
@@ -410,19 +407,19 @@ $ cargo build
410407
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
411408
```
412409

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?
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?
418415

419416
The answer to this problem is the `Cargo.lock` file you’ll now find in your
420417
project directory. When you build your project for the first time, Cargo
421418
figures out all of the versions that fit your criteria, and then writes them
422419
to the `Cargo.lock` file. When you build your project in the future, Cargo
423420
will see that the `Cargo.lock` file exists, and then use that specific version
424421
rather than do all the work of figuring out versions again. This lets you
425-
have a repeatable build automatically. In other words, we’ll stay at `0.3.8`
422+
have a repeatable build automatically. In other words, we’ll stay at `0.3.0`
426423
until we explicitly upgrade, and so will anyone who we share our code with,
427424
thanks to the lock file.
428425

@@ -442,7 +439,8 @@ projects which are assembled out of a number of sub-packages.
442439
[doccargo]: http://doc.crates.io
443440
[doccratesio]: http://doc.crates.io/crates-io.html
444441

445-
Let’s get on to actually _using_ `rand`. Here’s our next step:
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:
446444

447445
```rust,ignore
448446
extern crate rand;

0 commit comments

Comments
 (0)