use super::ParallelSliceMut;
use rand::distributions::Uniform;
+use rand::seq::SliceRandom;
use rand::{thread_rng, Rng};
use std::cmp::Ordering::{Equal, Greater, Less};
// Sort using a completely random comparison function.
// This will reorder the elements *somehow*, but won't panic.
let mut v: Vec<_> = (0..100).collect();
- v.$f(|_, _| *thread_rng().choose(&[Less, Equal, Greater]).unwrap());
+ v.$f(|_, _| *[Less, Equal, Greater].choose(&mut thread_rng()).unwrap());
v.$f(|a, b| a.cmp(b));
for i in 0..v.len() {
assert_eq!(v[i], i);
[(); 10].$f(|a, b| a.cmp(b));
[(); 100].$f(|a, b| a.cmp(b));
- let mut v = [0xDEADBEEFu64];
+ let mut v = [0xDEAD_BEEFu64];
v.$f(|a, b| a.cmp(b));
- assert!(v == [0xDEADBEEF]);
+ assert!(v == [0xDEAD_BEEF]);
}
};
}
// the second item represents which occurrence of that
// number this element is, i.e. the second elements
// will occur in sorted order.
+ let mut rng = thread_rng();
let mut v: Vec<_> = (0..len)
.map(|_| {
- let n = thread_rng().gen_range::<usize>(0, 10);
+ let n: usize = rng.gen_range(0, 10);
counts[n] += 1;
(n, counts[n])
})