File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
Sources/RectangleTools/Synthesized Conveniences
Tests/RectangleToolsTests Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -279,3 +279,37 @@ public extension TwoDimensional where Length: SignedNumeric {
279279 measurementY: - lhs. measurementY)
280280 }
281281}
282+
283+
284+
285+ // MARK: - Operators
286+
287+ public extension TwoDimensional where Length: AdditiveArithmetic {
288+ static func + ( multiplier: Length , value: Self ) -> Self {
289+ . init(
290+ measurementX: multiplier + value. measurementX,
291+ measurementY: multiplier + value. measurementY
292+ )
293+ }
294+
295+
296+ static func + ( value: Self , multiplier: Length ) -> Self {
297+ multiplier + value
298+ }
299+ }
300+
301+
302+
303+ public extension TwoDimensional where Length: MultiplicativeArithmetic {
304+ static func * ( multiplier: Length , value: Self ) -> Self {
305+ . init(
306+ measurementX: multiplier * value. measurementX,
307+ measurementY: multiplier * value. measurementY
308+ )
309+ }
310+
311+
312+ static func * ( value: Self , multiplier: Length ) -> Self {
313+ multiplier * value
314+ }
315+ }
Original file line number Diff line number Diff line change 1+ //
2+ // TwoDimensional operator tests.swift
3+ // RectangleTools
4+ //
5+ // Created by Ky on 2025-03-22.
6+ //
7+
8+ import Testing
9+
10+
11+
12+ struct TwoDimensional_operatorTests {
13+ @Test
14+ func testMultiply( ) async throws {
15+ < #body#>
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments