ConvertibleToDouble instead of Numeric
This commit is contained in:
@@ -340,28 +340,36 @@ public struct UnitValue<ValueType: ConvertibleToDouble>:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The result will have the `unit` of the left hand side value.
|
/// 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>
|
-> UnitValue<Double>
|
||||||
{
|
{
|
||||||
(lhs.value - rhs.value)[lhs.unit]
|
(lhs.value - rhs.value)[lhs.unit]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The result will have the `unit` of the left hand side value.
|
/// 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>
|
-> UnitValue<Double>
|
||||||
{
|
{
|
||||||
(lhs.value + rhs.value)[lhs.unit]
|
(lhs.value + rhs.value)[lhs.unit]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The result will have the `unit` of the left hand side value.
|
/// 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>
|
-> UnitValue<Double>
|
||||||
{
|
{
|
||||||
(lhs.value * rhs.value)[lhs.unit]
|
(lhs.value * rhs.value)[lhs.unit]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The result will have the `unit` of the left hand side value.
|
/// 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>
|
-> UnitValue<Double>
|
||||||
{
|
{
|
||||||
guard rhs.value != 0 else {
|
guard rhs.value != 0 else {
|
||||||
|
|||||||
Reference in New Issue
Block a user