removed unsafe block from rand-choose.md (#536)

the unsafe block in this example is not necessary and might confuse beginners.
This commit is contained in:
Stefan Hoelzl 2019-09-19 20:56:04 +02:00 committed by Andrew Gauger
parent 3d90852592
commit 6d3f7f97a2

View file

@ -19,8 +19,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());
// This is safe because `idx` is in range of `CHARSET` CHARSET[idx] as char
char::from(unsafe { *CHARSET.get_unchecked(idx) })
}) })
.collect(); .collect();