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:
Vegard Berg 2021-01-02 00:24:59 +01:00 committed by GitHub
parent 714e9f4fcd
commit 8d0d2e3fb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 5 deletions

View file

@ -37,8 +37,8 @@ num_cpus = "1.8"
percent-encoding = "2.1" percent-encoding = "2.1"
petgraph = "0.4" petgraph = "0.4"
postgres = "0.17.2" postgres = "0.17.2"
rand = "0.7.3" rand = "0.8.0"
rand_distr = "0.2.2" rand_distr = "0.4.0"
rayon = "1.0" rayon = "1.0"
regex = "1.0" regex = "1.0"
reqwest = { version = "0.10", features = ["blocking", "json", "stream"] } reqwest = { version = "0.10", features = ["blocking", "json", "stream"] }

View file

@ -16,7 +16,7 @@ fn main() {
let password: String = (0..PASSWORD_LEN) let password: String = (0..PASSWORD_LEN)
.map(|_| { .map(|_| {
let idx = rng.gen_range(0, CHARSET.len()); let idx = rng.gen_range(0..CHARSET.len());
CHARSET[idx] as char CHARSET[idx] as char
}) })
.collect(); .collect();

View file

@ -13,6 +13,7 @@ fn main() {
let rand_string: String = thread_rng() let rand_string: String = thread_rng()
.sample_iter(&Alphanumeric) .sample_iter(&Alphanumeric)
.take(30) .take(30)
.map(char::from)
.collect(); .collect();
println!("{}", rand_string); println!("{}", rand_string);

View file

@ -9,8 +9,8 @@ use rand::Rng;
fn main() { fn main() {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
println!("Integer: {}", rng.gen_range(0, 10)); println!("Integer: {}", rng.gen_range(0..10));
println!("Float: {}", rng.gen_range(0.0, 10.0)); println!("Float: {}", rng.gen_range(0.0..10.0));
} }
``` ```