Feature Request: saturating_add(Duration) for SystemTime / Instant (original) (raw)

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:

  1. allowing for the (hopefully very remote) potential for overflows
  2. determining what to do with the None case of the checked_add()
  3. 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(...?).