ConvertibleToDouble instead of Numeric

This commit is contained in:
cdricms
2025-08-08 10:24:09 +02:00
parent caf19895f3
commit ea2d1d81a7

View File

@@ -340,28 +340,36 @@ public struct UnitValue<ValueType: ConvertibleToDouble>:
}
/// The result will have the `unit` of the left hand side value.
public static func - <T: Numeric>(lhs: UnitValue<T>, rhs: UnitValue<T>)
public static func - <T: ConvertibleToDouble>(
lhs: UnitValue<T>, rhs: UnitValue<T>
)
-> UnitValue<Double>
{
(lhs.value - rhs.value)[lhs.unit]
}
/// The result will have the `unit` of the left hand side value.
public static func + <T: Numeric>(lhs: UnitValue<T>, rhs: UnitValue<T>)
public static func + <T: ConvertibleToDouble>(
lhs: UnitValue<T>, rhs: UnitValue<T>
)
-> UnitValue<Double>
{
(lhs.value + rhs.value)[lhs.unit]
}
/// The result will have the `unit` of the left hand side value.
public static func * <T: Numeric>(lhs: UnitValue<T>, rhs: UnitValue<T>)
public static func * <T: ConvertibleToDouble>(
lhs: UnitValue<T>, rhs: UnitValue<T>
)
-> UnitValue<Double>
{
(lhs.value * rhs.value)[lhs.unit]
}
/// The result will have the `unit` of the left hand side value.
public static func / <T: Numeric>(lhs: UnitValue<T>, rhs: UnitValue<T>)
public static func / <T: ConvertibleToDouble>(
lhs: UnitValue<T>, rhs: UnitValue<T>
)
-> UnitValue<Double>
{
guard rhs.value != 0 else {