Open
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(...?)
.