mirror of
https://github.com/rust-lang-nursery/rust-cookbook
synced 2024-11-21 11:03:09 +00:00
Updated rand_distr
, fixed and updated rand
. (#627)
The `rand` crate has been updated to version `0.8.0`, and has its code samples updated. The `rand_distr` crate has been updated to version `0.4.0`.
This commit is contained in:
parent
714e9f4fcd
commit
8d0d2e3fb1
4 changed files with 6 additions and 5 deletions
|
@ -37,8 +37,8 @@ num_cpus = "1.8"
|
|||
percent-encoding = "2.1"
|
||||
petgraph = "0.4"
|
||||
postgres = "0.17.2"
|
||||
rand = "0.7.3"
|
||||
rand_distr = "0.2.2"
|
||||
rand = "0.8.0"
|
||||
rand_distr = "0.4.0"
|
||||
rayon = "1.0"
|
||||
regex = "1.0"
|
||||
reqwest = { version = "0.10", features = ["blocking", "json", "stream"] }
|
||||
|
|
|
@ -16,7 +16,7 @@ fn main() {
|
|||
|
||||
let password: String = (0..PASSWORD_LEN)
|
||||
.map(|_| {
|
||||
let idx = rng.gen_range(0, CHARSET.len());
|
||||
let idx = rng.gen_range(0..CHARSET.len());
|
||||
CHARSET[idx] as char
|
||||
})
|
||||
.collect();
|
||||
|
|
|
@ -13,6 +13,7 @@ fn main() {
|
|||
let rand_string: String = thread_rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(30)
|
||||
.map(char::from)
|
||||
.collect();
|
||||
|
||||
println!("{}", rand_string);
|
||||
|
|
|
@ -9,8 +9,8 @@ use rand::Rng;
|
|||
|
||||
fn main() {
|
||||
let mut rng = rand::thread_rng();
|
||||
println!("Integer: {}", rng.gen_range(0, 10));
|
||||
println!("Float: {}", rng.gen_range(0.0, 10.0));
|
||||
println!("Integer: {}", rng.gen_range(0..10));
|
||||
println!("Float: {}", rng.gen_range(0.0..10.0));
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue