version = "0.1.0"
[dependencies]
-rand = { git = "https://github.com/rust-lang-nursery/rand.git" }
+regex = { git = "https://github.com/rust-lang/regex.git" }
```
-This package has a single dependency, on the `rand` library. We’ve stated in
+This package has a single dependency, on the `regex` library. We’ve stated in
this case that we’re relying on a particular Git repository that lives on
GitHub. Since we haven’t specified any other information, Cargo assumes that
we intend to use the latest commit on the `master` branch to build our package.
Sound good? Well, there’s one problem: If you build this package today, and
then you send a copy to me, and I build this package tomorrow, something bad
-could happen. There could be more commits to `rand` in the meantime, and my
+could happen. There could be more commits to `regex` in the meantime, and my
build would include new commits while yours would not. Therefore, we would
get different builds. This would be bad because we want reproducible builds.
```toml
[dependencies]
-rand = { git = "https://github.com/rust-lang-nursery/rand.git", rev = "9f35b8e" }
+regex = { git = "https://github.com/rust-lang/regex.git", rev = "9f9f693" }
```
Now our builds will be the same. But there’s a big drawback: now we have to
version = "0.1.0"
[dependencies]
-rand = { git = "https://github.com/rust-lang-nursery/rand.git" }
+regex = { git = "https://github.com/rust-lang/regex.git" }
```
Cargo will take the latest commit and write that information out into our
name = "hello_world"
version = "0.1.0"
dependencies = [
- "rand 0.1.0 (git+https://github.com/rust-lang-nursery/rand.git#9f35b8e439eeedd60b9414c58f389bdc6a3284f9)",
+ "regex 1.5.0 (git+https://github.com/rust-lang/regex.git#9f9f693768c584971a4d53bc3c586c33ed3a6831)",
]
[[package]]
-name = "rand"
-version = "0.1.0"
-source = "git+https://github.com/rust-lang-nursery/rand.git#9f35b8e439eeedd60b9414c58f389bdc6a3284f9"
+name = "regex"
+version = "1.5.0"
+source = "git+https://github.com/rust-lang/regex.git#9f9f693768c584971a4d53bc3c586c33ed3a6831"
```
You can see that there’s a lot more information here, including the exact
re-calculate the dependencies and update things for us:
```console
-$ cargo update # updates all dependencies
-$ cargo update -p rand # updates just “rand”
+$ cargo update # updates all dependencies
+$ cargo update -p regex # updates just “regex”
```
This will write out a new `Cargo.lock` with the new version information. Note
that the argument to `cargo update` is actually a
-[Package ID Specification](../reference/pkgid-spec.md) and `rand` is just a short
-specification.
+[Package ID Specification](../reference/pkgid-spec.md) and `regex` is just a
+short specification.
[def-manifest]: ../appendix/glossary.md#manifest '"manifest" (glossary entry)'
[def-package]: ../appendix/glossary.md#package '"package" (glossary entry)'
If you download an existing [package][def-package] that uses Cargo, it’s
really easy to get going.
-First, get the package from somewhere. In this example, we’ll use `rand`
+First, get the package from somewhere. In this example, we’ll use `regex`
cloned from its repository on GitHub:
```console
-$ git clone https://github.com/rust-lang-nursery/rand.git
-$ cd rand
+$ git clone https://github.com/rust-lang/regex.git
+$ cd regex
```
To build, use `cargo build`:
```console
$ cargo build
- Compiling rand v0.1.0 (file:///path/to/package/rand)
+ Compiling regex v1.5.0 (file:///path/to/package/regex)
```
This will fetch all of the dependencies and then build them, along with the