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)
.map(|_| {
let idx = rng.gen_range(0, CHARSET.len());
// This is safe because `idx` is in range of `CHARSET`
char::from(unsafe { *CHARSET.get_unchecked(idx) })
CHARSET[idx] as char
})
.collect();