Merge pull request #72 from mjkeating/remove_saturated_sub

removed unnecessary call to saturated_sub() in vec_shuffle
This commit is contained in:
Paul Hauner 2018-11-24 15:05:40 +11:00 committed by GitHub
commit ba548e49a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,7 +29,7 @@ pub fn shuffle<T>(seed: &[u8], mut list: Vec<T>) -> Result<Vec<T>, ShuffleErr> {
return Ok(list);
}
for i in 0..(list.len().saturating_sub(1)) {
for i in 0..(list.len() - 1) {
let n = list.len() - i;
let j = rng.rand_range(n as u32) as usize + i;
list.swap(i, j);