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

Fixes for Duration::new #1405

Merged
merged 2 commits into from
Feb 4, 2024
Merged

Conversation

pitdicker
Copy link
Collaborator

Thanks to @Skgland in #1337 (comment) for noticing.

Copy link

codecov bot commented Feb 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b92b736) 91.84% compared to head (67277eb) 91.84%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1405   +/-   ##
=======================================
  Coverage   91.84%   91.84%           
=======================================
  Files          38       38           
  Lines       17518    17518           
=======================================
  Hits        16090    16090           
  Misses       1428     1428           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@djc
Copy link
Member

djc commented Feb 2, 2024

If we're going to make this public, should we instead do a div_mod for nanos and add the modulo to the seconds?

@pitdicker
Copy link
Collaborator Author

pitdicker commented Feb 2, 2024

If we're going to make this public, should we instead do a div_mod for nanos and add the modulo to the seconds?

I like that it now is just the most basic way to set the fields of a Duration.

std::time::Duration::new does carry over nanoseconds beyond 1.000.000.000 to seconds. That adds another case that makes it fallible:

Panics

This constructor will panic if the carry from the nanoseconds overflows the seconds counter.

@pitdicker pitdicker merged commit ae695a4 into chronotope:main Feb 4, 2024
37 checks passed
@pitdicker pitdicker deleted the duration_new_fixes branch February 4, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants