Base unit available for everyone
This commit is contained in:
@@ -329,8 +329,8 @@ public struct UnitValue<ValueType: ConvertibleToDouble>:
|
||||
-> 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<ValueType: ConvertibleToDouble>:
|
||||
"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<ValueType: ConvertibleToDouble>:
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user