From 7f23aaa6743b59fd2eecc9f1444dd9cb04ba10de Mon Sep 17 00:00:00 2001 From: cdricms <36056008+cdricms@users.noreply.github.com> Date: Sat, 27 Sep 2025 19:16:54 +0200 Subject: [PATCH] Base unit available for everyone --- Sources/Units/Units.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Units/Units.swift b/Sources/Units/Units.swift index 077bf6f..ca3a83d 100644 --- a/Sources/Units/Units.swift +++ b/Sources/Units/Units.swift @@ -329,8 +329,8 @@ public struct UnitValue: -> Bool { // For equality, convert both to base unit for comparison - guard let lhsBase = lhs.converted(to: lhs.unit.category.baseUnit()), - let rhsBase = rhs.converted(to: rhs.unit.category.baseUnit()) + guard let lhsBase = lhs.converted(to: lhs.unit.category.baseUnit), + let rhsBase = rhs.converted(to: rhs.unit.category.baseUnit) else { return false // Or handle error appropriately } @@ -345,8 +345,8 @@ public struct UnitValue: "Cannot compare UnitValues of different categories (\(lhs.unit.category) vs \(rhs.unit.category))" ) } - guard let lhsBase = lhs.converted(to: lhs.unit.category.baseUnit()), - let rhsBase = rhs.converted(to: rhs.unit.category.baseUnit()) + guard let lhsBase = lhs.converted(to: lhs.unit.category.baseUnit), + let rhsBase = rhs.converted(to: rhs.unit.category.baseUnit) else { return false } @@ -464,7 +464,7 @@ public struct UnitValue: // Helper to get the base unit for a category extension UnitCategory { - func baseUnit() -> Unit { + public var baseUnit: Unit { switch self { case .mass: return .gram case .length: return .meter