]> git.nega.tv - josh/narcissus/commitdiff
narcissus-core: Fix clippy lints
authorJoshua Simmons <josh@nega.tv>
Sun, 5 Nov 2023 11:35:37 +0000 (12:35 +0100)
committerJoshua Simmons <josh@nega.tv>
Sun, 5 Nov 2023 11:35:37 +0000 (12:35 +0100)
libs/narcissus-core/src/finite.rs
libs/narcissus-core/src/linear_log_binning.rs
libs/narcissus-core/src/mutex.rs

index a5e59d2e694466b334af410324b47e4f02345723..48c0e1b8fc9da6f4960e57e6b0a4cc9909f8bbc1 100644 (file)
@@ -46,7 +46,7 @@ impl Eq for FiniteF32 {}
 impl PartialOrd for FiniteF32 {
     #[inline(always)]
     fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
-        self.0.partial_cmp(&other.0)
+        Some(self.cmp(other))
     }
 }
 
@@ -103,7 +103,7 @@ impl Eq for FiniteF64 {}
 impl PartialOrd for FiniteF64 {
     #[inline(always)]
     fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
-        self.0.partial_cmp(&other.0)
+        Some(self.cmp(other))
     }
 }
 
index b3b0017f4108f73f0fa8f1ef314d18b6c9f841cb..77d1678fce6352d14402c1653d03f6868b6677e3 100644 (file)
@@ -217,16 +217,16 @@ mod tests {
         // Check all bin thresholds.
         for i in 0..32 - LINEAR_REGION_LOG2 - 1 {
             let bin = i + 1;
-            let base = 1 << i + LINEAR_REGION_LOG2;
+            let base = 1 << (i + LINEAR_REGION_LOG2);
             let step = base >> SUB_BIN_COUNT_LOG2;
-            for sub_bin in 0..SUB_BIN_COUNT as u32 {
+            for sub_bin in 0..SUB_BIN_COUNT {
                 let size = base + sub_bin * step;
                 assert_eq!(Bin::from_size_round_up(size), make_bin(size, bin, sub_bin));
                 assert_eq!(make_bin(size, bin, sub_bin), (size, Bin::new(bin, sub_bin)));
 
                 let next_size = base + (sub_bin + 1) * step;
-                let next_bin = bin + (sub_bin == SUB_BIN_COUNT as u32 - 1) as u32;
-                let next_sub_bin = (sub_bin + 1) % SUB_BIN_COUNT as u32;
+                let next_bin = bin + (sub_bin == SUB_BIN_COUNT - 1) as u32;
+                let next_sub_bin = (sub_bin + 1) % SUB_BIN_COUNT;
                 assert_eq!(
                     Bin::from_size_round_up(size + 1),
                     make_bin(next_size, next_bin, next_sub_bin)
index e5dd569bb99a1bd57d71001ab5f22471a1876474..d0b3ca64097560187fa80d2bc9f56dc3277e192d 100644 (file)
@@ -263,23 +263,17 @@ mod tests {
         let mutex = Mutex::new(1);
         let mut lock1;
         loop {
-            match mutex.try_lock() {
-                Some(lock) => {
-                    lock1 = lock;
-                    break;
-                }
-                None => {}
+            if let Some(lock) = mutex.try_lock() {
+                lock1 = lock;
+                break;
             }
         }
 
         let mut lock2;
         loop {
-            match mutex.try_lock() {
-                Some(lock) => {
-                    lock2 = lock;
-                    break;
-                }
-                None => {}
+            if let Some(lock) = mutex.try_lock() {
+                lock2 = lock;
+                break;
             }
         }