mirror of
https://github.com/rust-lang-nursery/rust-cookbook
synced 2024-11-24 20:43:07 +00:00
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:
parent
3d90852592
commit
6d3f7f97a2
1 changed files with 1 additions and 2 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue