Skip to content

Commit 8d0d2e3

Browse files
authored
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`.
1 parent 714e9f4 commit 8d0d2e3

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ num_cpus = "1.8"
3737
percent-encoding = "2.1"
3838
petgraph = "0.4"
3939
postgres = "0.17.2"
40-
rand = "0.7.3"
41-
rand_distr = "0.2.2"
40+
rand = "0.8.0"
41+
rand_distr = "0.4.0"
4242
rayon = "1.0"
4343
regex = "1.0"
4444
reqwest = { version = "0.10", features = ["blocking", "json", "stream"] }

src/algorithms/randomness/rand-choose.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn main() {
1616
1717
let password: String = (0..PASSWORD_LEN)
1818
.map(|_| {
19-
let idx = rng.gen_range(0, CHARSET.len());
19+
let idx = rng.gen_range(0..CHARSET.len());
2020
CHARSET[idx] as char
2121
})
2222
.collect();

src/algorithms/randomness/rand-passwd.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ fn main() {
1313
let rand_string: String = thread_rng()
1414
.sample_iter(&Alphanumeric)
1515
.take(30)
16+
.map(char::from)
1617
.collect();
1718
1819
println!("{}", rand_string);

src/algorithms/randomness/rand-range.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use rand::Rng;
99
1010
fn main() {
1111
let mut rng = rand::thread_rng();
12-
println!("Integer: {}", rng.gen_range(0, 10));
13-
println!("Float: {}", rng.gen_range(0.0, 10.0));
12+
println!("Integer: {}", rng.gen_range(0..10));
13+
println!("Float: {}", rng.gen_range(0.0..10.0));
1414
}
1515
```
1616

0 commit comments

Comments
 (0)