Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/time: Add Duration methods for zero #72790

Merged
merged 3 commits into from
Jun 21, 2020
Merged

Commits on Jun 20, 2020

  1. core/time: Add Duration methods for zero

    This patch adds two methods to `Duration`. The first, `Duration::zero`,
    provides a `const` constructor for getting an zero-length duration. This
    is also what `Default` provides (this was clarified in the docs), though
    `default` is not `const`.
    
    The second, `Duration::is_zero`, returns true if a `Duration` spans no
    time (i.e., because its components are all zero). Previously, the way to
    do this was either to compare both `as_secs` and `subsec_nanos` to 0, to
    compare against `Duration::new(0, 0)`, or to use the `u128` method
    `as_nanos`, none of which were particularly elegant.
    jonhoo committed Jun 20, 2020
    Configuration menu
    Copy the full SHA
    3ff5879 View commit details
    Browse the repository at this point in the history
  2. Doctests need feature

    jonhoo committed Jun 20, 2020
    Configuration menu
    Copy the full SHA
    ad7fd62 View commit details
    Browse the repository at this point in the history
  3. Revise according to review

    jonhoo committed Jun 20, 2020
    Configuration menu
    Copy the full SHA
    386114b View commit details
    Browse the repository at this point in the history