Maybe more rustic way of building a random password.

This commit is contained in:
Rasmus Kaj 2022-02-17 23:42:31 +01:00
parent 8b6078fb7d
commit 5217b51926

View File

@ -46,6 +46,8 @@ fn random_password(len: usize) -> String {
let rng = thread_rng();
// Note; I would like to have lowercase letters more probable
use rand::distributions::Alphanumeric;
String::from_utf8(rng.sample_iter(&Alphanumeric).take(len).collect())
.unwrap()
rng.sample_iter(&Alphanumeric)
.map(char::from)
.take(len)
.collect()
}