replace extern create rand with use rand

reasons:

- `extern crate` is almost never needed since Rust 2018.
- `extern crate` is neither mentioned nor explained between ch01~ch14, makes beginners confused..
This commit is contained in:
Jian Weihang
2019-02-10 15:46:54 +08:00
parent e6a8894a11
commit 9f55bd4bc6
+2 -3
View File
@@ -218,9 +218,8 @@ $ cargo build
The top-level *Cargo.lock* now contains information about the dependency of
`add-one` on `rand`. However, even though `rand` is used somewhere in the
workspace, we can’t use it in other crates in the workspace unless we add
`rand` to their *Cargo.toml* files as well. For example, if we add `extern
crate rand;` to the *adder/src/main.rs* file for the `adder` crate, we’ll get
an error:
`rand` to their *Cargo.toml* files as well. For example, if we add `use rand;`
to the *adder/src/main.rs* file for the `adder` crate, we’ll get an error:
```text
$ cargo build