So I have a struct with the following declaration.
public struct Rational<IntegerType : UnsignedInteger & FixedWidthInteger> {
public let numerator: IntegerType
public let denominator: IntegerType
internal init(_ numerator: IntegerType,
_ denominator: IntegerType,
reduce: Bool = false) {
/// Implementation...
}
}
This initializer gives me the following error:
Cannot convert value of type 'T.Magnitude' to expected argument type 'IntegerType'.
public init<T : BinaryInteger>(_ numerator: T,
_ denominator: T)
where IntegerType == T.Magnitude {
self.init(numerator.magnitude,
denominator.magnitude,
reduce: true)
}
It seems to be ignoring the where clause entirely.