From 6d3f7f97a2fe02d2900933dc28e9a825d16daa91 Mon Sep 17 00:00:00 2001 From: Stefan Hoelzl Date: Thu, 19 Sep 2019 20:56:04 +0200 Subject: [PATCH] removed unsafe block from rand-choose.md (#536) the unsafe block in this example is not necessary and might confuse beginners. --- src/algorithms/randomness/rand-choose.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/algorithms/randomness/rand-choose.md b/src/algorithms/randomness/rand-choose.md index 8a95c63..acb61fe 100644 --- a/src/algorithms/randomness/rand-choose.md +++ b/src/algorithms/randomness/rand-choose.md @@ -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();