tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1061HTML 997Markdown 12TOML 83120 Definiciones

Remove manual map implementation in maybe math (#161)

03fc090799a3b3851f229170cea4735eca593cae · por TimJentzsch · (hace 4 años) · padre d35459ebd · ver el árbol en este commit

Delta semántico · 4

src/math.rs

1 archivos · +4 −22

diff --git a/src/math.rs b/src/math.rs
index 687192bba..cd9ad6512 100644
--- a/src/math.rs
+++ b/src/math.rs
@@ -57,38 +57,20 @@ impl MaybeMath<Option<f32>, Option<f32>> for Option<f32> {
 }
 
 impl MaybeMath<f32, Option<f32>> for Option<f32> {
-    // The logic here is subtle and critical;
-    // explicit match statements make it more clear what's going on
-    #[allow(clippy::manual_map)]
     fn maybe_min(self, rhs: f32) -> Option<f32> {
-        match self {
-            Some(val) => Some(val.min(rhs)),
-            None => None,
-        }
+        self.map(|val| val.min(rhs))
     }
 
-    #[allow(clippy::manual_map)]
     fn maybe_max(self, rhs: f32) -> Option<f32> {
-        match self {
-            Some(val) => Some(val.max(rhs)),
-            None => None,
-        }
+        self.map(|val| val.max(rhs))
     }
 
-    #[allow(clippy::manual_map)]
     fn maybe_add(self, rhs: f32) -> Option<f32> {
-        match self {
-            Some(val) => Some(val + rhs),
-            None => None,
-        }
+        self.map(|val| val + rhs)
     }
 
-    #[allow(clippy::manual_map)]
     fn maybe_sub(self, rhs: f32) -> Option<f32> {
-        match self {
-            Some(val) => Some(val - rhs),
-            None => None,
-        }
+        self.map(|val| val - rhs)
     }
 }