From 551177803d856e28cc63d460d7579342bc1867e1 Mon Sep 17 00:00:00 2001 From: cdricms <36056008+cdricms@users.noreply.github.com> Date: Sat, 13 Sep 2025 23:24:55 +0200 Subject: [PATCH] Will it work --- Sources/Units/Units.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/Units/Units.swift b/Sources/Units/Units.swift index 8fd8909..56c3b74 100644 --- a/Sources/Units/Units.swift +++ b/Sources/Units/Units.swift @@ -412,6 +412,16 @@ public struct UnitValue: return (lhs.value * rhs.value)[lhs.unit] } + public func operation( + value: any ConvertibleToDouble, + op: ( + _ lhs: + any ConvertibleToDouble, _ rhs: any ConvertibleToDouble + ) -> any ConvertibleToDouble + ) -> UnitValue { + op(self.value, value).doubleValue[self.unit] + } + // MARK: - Subscripts for UnitValue /// Allows converting the UnitValue to another Unit using subscript syntax. /// Example: `tenKilos[.pound]`