mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 07:20:20 +08:00
doc: Update the sample code
This commit is contained in:
parent
c9c49457d7
commit
75f6f53c7d
@ -181,7 +181,7 @@ pub fn eat_at_restaurant() {
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
rand = "0.5.5"
|
||||
rand = "0.8.3"
|
||||
```
|
||||
|
||||
在 *Cargo.toml* 中加入 `rand` 依赖告诉了 Cargo 要从 [crates.io](https://crates.io) 下载 `rand` 和其依赖,并使其可在项目代码中使用。
|
||||
@ -192,7 +192,7 @@ rand = "0.5.5"
|
||||
use rand::Rng;
|
||||
|
||||
fn main() {
|
||||
let secret_number = rand::thread_rng().gen_range(1, 101);
|
||||
let secret_number = rand::thread_rng().gen_range(1..101);
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user