-
Notifications
You must be signed in to change notification settings - Fork 533
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
Add checked_mul and checked_div #1565
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1565 +/- ##
==========================================
+ Coverage 91.80% 91.81% +0.01%
==========================================
Files 37 37
Lines 18151 18164 +13
==========================================
+ Hits 16664 16678 +14
+ Misses 1487 1486 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you spot other unhandled cases let me know.
Not that easy to spot 😆.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Half-open range patterns became stable in Rust 1.59.0, the CI is on an older version so i had to use full ranges
|
The CI is checking our MSRV of 1.61. |
Woops! Half-open ranges work on my system (TM) : Rust 1.74. So it got stable somewhere in between. |
Rust 1.66 stabilized the feature: https://blog.rust-lang.org/2022/12/15/Rust-1.66.0.html#other-changes |
Adds checked variants of
TimeDelta::mul
andTimeDelta::div
as proposed in #1469.If you spot other unhandled cases let me know.
Regarding
checked_div
, I think it is impossible to overflow because you cannot divide by integers between -1 and +1 other than 0.cc @pitdicker