Skip to content

More methods for std::time::Duration #1917

Open
@clarfonthey

Description

@clarfonthey

Right now, we have:

  • from_secs
  • from_millis
  • as_secs
  • subsec_nanos

It'd be nice if we also had:

  • from_hours (note: potential for overflow)
  • from_mins (note: potential for overflow)
  • from_micros
  • from_nanos
  • as_hours
  • as_mins
  • subsec_millis
  • subsec_micros

And potentially also:

  • from_days (note: potential for overflow)
  • as_days
  • as_millis (note: potential for overflow)
  • as_micros (note: potential for overflow)
  • as_nanos (note: potential for overflow)

(Note that as_millis is already suggested by #1545).

time::Duration already has a lot of these, and it'd be nice if the libstd version did too. These don't seem that hard to implement or maintain, and they seem useful enough to have.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions