-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Change rand version to '*' #25179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Change rand version to '*' #25179
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -358,11 +358,10 @@ rand="0.3.0" | |
The `[dependencies]` section of `Cargo.toml` is like the `[package]` section: | ||
everything that follows it is part of it, until the next section starts. | ||
Cargo uses the dependencies section to know what dependencies on external | ||
crates you have, and what versions you require. In this case, we’ve used `*`, | ||
which means that we’ll use the latest version of `rand`. Cargo understands | ||
[Semantic Versioning][semver], which is a standard for writing version | ||
numbers. If we wanted a specific version or range of versions, we could be | ||
more specific here. [Cargo’s documentation][cargodoc] contains more details. | ||
crates you have, and what versions you require. In this case, we’ve used version `0.3.0`. | ||
Cargo understands [Semantic Versioning][semver], which is a standard for writing version | ||
numbers. If we wanted to use the latest version we could use `*` or we could use a range | ||
of versions. [Cargo’s documentation][cargodoc] contains more details. | ||
|
||
[semver]: http://semver.org | ||
[cargodoc]: http://doc.crates.io/crates-io.html | ||
|
@@ -372,15 +371,13 @@ Now, without changing any of our code, let’s build our project: | |
```bash | ||
$ cargo build | ||
Updating registry `https://github.com/rust-lang/crates.io-index` | ||
Downloading rand v0.3.8 | ||
Downloading rand v0.3.0 | ||
Downloading libc v0.1.6 | ||
Compiling libc v0.1.6 | ||
Compiling rand v0.3.8 | ||
Compiling rand v0.3.0 | ||
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game) | ||
``` | ||
|
||
(You may see different versions, of course.) | ||
|
||
Lots of new output! Now that we have an external dependency, Cargo fetches the | ||
latest versions of everything from the registry, which is a copy of data from | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually important, as if a 0.3.9 comes out, it will get used. or a 0.3.10. just not 0.4.0 |
||
[Crates.io][cratesio]. Crates.io is where people in the Rust ecosystem | ||
|
@@ -410,19 +407,19 @@ $ cargo build | |
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game) | ||
``` | ||
|
||
So, we told Cargo we wanted any version of `rand`, and so it fetched the latest | ||
version at the time this was written, `v0.3.8`. But what happens when next | ||
week, version `v0.3.9` comes out, with an important bugfix? While getting | ||
bugfixes is important, what if `0.3.9` contains a regression that breaks our | ||
code? | ||
Let's pretend that we told Cargo we wanted the latest version of `rand` (using `*`) | ||
for a bit. It would have fetched `v0.3.8` (at the time this was written). | ||
But what happens when next week, version `v0.3.9` comes out, with an important | ||
bugfix? While getting bugfixes is important, what if `0.3.9` contains a regression | ||
that breaks our code? | ||
|
||
The answer to this problem is the `Cargo.lock` file you’ll now find in your | ||
project directory. When you build your project for the first time, Cargo | ||
figures out all of the versions that fit your criteria, and then writes them | ||
to the `Cargo.lock` file. When you build your project in the future, Cargo | ||
will see that the `Cargo.lock` file exists, and then use that specific version | ||
rather than do all the work of figuring out versions again. This lets you | ||
have a repeatable build automatically. In other words, we’ll stay at `0.3.8` | ||
have a repeatable build automatically. In other words, we’ll stay at `0.3.0` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing here |
||
until we explicitly upgrade, and so will anyone who we share our code with, | ||
thanks to the lock file. | ||
|
||
|
@@ -442,7 +439,8 @@ projects which are assembled out of a number of sub-packages. | |
[doccargo]: http://doc.crates.io | ||
[doccratesio]: http://doc.crates.io/crates-io.html | ||
|
||
Let’s get on to actually _using_ `rand`. Here’s our next step: | ||
Let’s get on to actually _using_ `rand`. Keep the version as `0.3.0` for this | ||
project. Here’s our next step: | ||
|
||
```rust,ignore | ||
extern crate rand; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two sets shouldn't change, actually... more below