Przeglądaj źródła

Rework opBinary to avoid duplicating code

Steven Schveighoffer 1 rok temu
rodzic
commit
31ae45bf9b
1 zmienionych plików z 1 dodań i 7 usunięć
  1. 1 7
      source/raylib/raylib_types.d

+ 1 - 7
source/raylib/raylib_types.d

@@ -99,13 +99,7 @@ struct Rectangle
 
     Rectangle opBinary(string op)(Vector2 offset) const if(op=="+" || op=="-") {
         Rectangle result = this;
-        static if (op=="+") {
-            result.x += offset.x;
-            result.y += offset.y;
-        } else static if (op=="-") {
-            result.x -= offset.x;
-            result.y -= offset.y;
-        }
+        result.opOpAssign!op(offset);
         return result;
     }
 }