-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-timeArea: TimeArea: TimeC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Both SystemTime
and Instant
have checked_add(Duration)
, but no saturating_add(Duration)
.
This seems like an omission, as when doing math operations on time, a developer has to choose between:
- allowing for the (hopefully very remote) potential for overflows
- determining what to do with the
None
case of thechecked_add()
- letting it
checked_add(long_duration).unwrap()
panic after an overflow
Given that the SystemTime
and Instant
both opaquely wrap a platform-dependent structure, it's not clear what "far future" values are valid on a given platform (e.g. issue #44394), and what values a developer could correctly use with checked_add(long_duration).unwrap_or(...?)
.
scottmcm, mdsteele, tarcieri, itsCryne, MaxFangX and 6 more
Metadata
Metadata
Assignees
Labels
A-timeArea: TimeArea: TimeC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.