Skip to content

Feature Request: saturating_add(Duration) for SystemTime / InstantΒ #71224

Open
@woody77

Description

@woody77

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-timeArea: TimeC-feature-requestCategory: 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions