-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Whole differences should return integers #81
Labels
Milestone
Comments
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
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.The text was updated successfully, but these errors were encountered: