]> git.proxmox.com Git - rustc.git/blobdiff - vendor/rustc-rayon/src/slice/test.rs
New upstream version 1.40.0+dfsg1
[rustc.git] / vendor / rustc-rayon / src / slice / test.rs
index 3899e67923b56a8cf34ea34fb2b30f64672d0216..d335318f1bae3b40c337ed865133dbb7e9e3d617 100644 (file)
@@ -2,6 +2,7 @@
 
 use super::ParallelSliceMut;
 use rand::distributions::Uniform;
+use rand::seq::SliceRandom;
 use rand::{thread_rng, Rng};
 use std::cmp::Ordering::{Equal, Greater, Less};
 
@@ -69,7 +70,7 @@ macro_rules! sort {
             // 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);
@@ -80,9 +81,9 @@ macro_rules! sort {
             [(); 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]);
         }
     };
 }
@@ -101,9 +102,10 @@ fn test_par_sort_stability() {
             // 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])
                 })