Feature Request: saturating_add(Duration) for SystemTime / Instant #71224
Labels
A-time
Area: Time
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Both
SystemTime
andInstant
havechecked_add(Duration)
, but nosaturating_add(Duration)
.This seems like an omission, as when doing math operations on time, a developer has to choose between:
None
case of thechecked_add()
checked_add(long_duration).unwrap()
panic after an overflowGiven that the
SystemTime
andInstant
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 withchecked_add(long_duration).unwrap_or(...?)
.The text was updated successfully, but these errors were encountered: