Open davedelong opened 7 months ago
Example:
public func differenceInWholeYears(to other: Self) -> TimeDifference<Year, Year> { ... }
@_disfavoredOverload
public func differenceInWholeYears(to other: Self) -> Int {
let difference: TimeDifference<Year, Year> = self.differenceInWholeYears(to: other)
return difference.years
}
The
differenceInWhole...
functions should just returnInt
values. The underlyingTimeDifference
, because of the nature of the computation, will only have a single represented value, so the extra indirection is unnecessary.This could be implemented by adding the new
Int
-returning methods but marking them as@_disfavoredOverload
; that would mean existing code would continue to compile without issues and would not require modifications.Eventually when Time reaches 2.0 status, the
@_disfavoredOverload
attribute could swap from theInt
-returning method to theTimeDifference
-returning method, because that's a source/API-breaking change, which is appropriate for a major version update.