fixed rand crate deprecation warning (#510)

This commit is contained in:
Yogesh 2019-04-12 20:48:01 +05:30 committed by Andrew Gauger
parent 539183c86b
commit 2ee24f4bc7
4 changed files with 5 additions and 5 deletions

View file

@ -8,14 +8,13 @@ Randomly generates a string of given length ASCII characters with custom user-de
extern crate rand;
use rand::seq::SliceRandom;
use rand::thread_rng;
fn main() {
const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz\
0123456789)(*&^%$#@!~";
let mut rng = thread_rng();
let mut rng = rand::thread_rng();
let password: Option<String> = (0..30)
.map(|_| Some(*CHARSET.choose(&mut rng)? as char))
.collect();

View file

@ -5,7 +5,7 @@
By default, random numbers have [uniform distribution].
To generate numbers with other distributions you instantiate a
distribution, then sample from that distribution using
[`IndependentSample::ind_sample`] with help of a random-number
[`Distribution::sample`] with help of a random-number
generator [`rand::Rng`].
The [distributions available are documented here][rand-distributions]. An example using the

View file

@ -16,13 +16,14 @@ fn main() {
}
```
[`Range`] can obtain values with [uniform distribution].
[`Uniform`] can obtain values with [uniform distribution].
This has the same effect, but may be faster when repeatedly generating numbers
in the same range.
```rust
extern crate rand;
use rand::distributions::{Distribution, Uniform};
fn main() {

View file

@ -4,7 +4,7 @@
Gets the current working directory by calling [`env::current_dir`],
then for each entries in [`fs::read_dir`], extracts the
[`DirEntry::path`] and gets the metada via [`fs::Metadata`]. The
[`DirEntry::path`] and gets the metadata via [`fs::Metadata`]. The
[`Metadata::modified`] returns the [`SystemTime::elapsed`] time since
last modification. [`Duration::as_secs`] converts the time to seconds and
compared with 24 hours (24 * 60 * 60 seconds). [`Metadata::is_file`] filters