Convert NaiveDate/NaiveDateTime::checked_(add/sub)_days to return Result#1475
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 0.5.x #1475 +/- ##
==========================================
- Coverage 94.02% 94.02% -0.01%
==========================================
Files 37 37
Lines 16974 16954 -20
==========================================
- Hits 15960 15941 -19
+ Misses 1014 1013 -1 ☔ View full report in Codecov by Sentry. |
pitdicker
reviewed
Mar 1, 2024
Contributor
Author
|
Thanks for the feedback, I will take it into account. Just haven't found time so far. |
Collaborator
|
Thank you for the update. There is no hurry. |
pitdicker
approved these changes
Mar 9, 2024
| /// NaiveDate::from_ymd(2022, 7, 31).unwrap().checked_add_days(Days::new(2)), | ||
| /// Some(NaiveDate::from_ymd(2022, 8, 2).unwrap()) | ||
| /// NaiveDate::from_ymd(2022, 2, 20)?.checked_add_days(Days::new(9)), | ||
| /// NaiveDate::from_ymd(2022, 3, 1) |
Collaborator
There was a problem hiding this comment.
Seems like a more interesting example 👍.
| fn next(&mut self) -> Option<Self::Item> { | ||
| let current = self.value; | ||
| self.value = current.checked_add_days(Days::new(7))?; | ||
| self.value = current.checked_add_days(Days::new(7)).ok()?; |
Collaborator
There was a problem hiding this comment.
Unrelated to this PR, so just ignore this comment.
I wonder if the NaiveDateWeeksIterator can cover the complete range of NaiveDate, or if it fails one week before the end.
djc
approved these changes
Mar 11, 2024
Collaborator
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request targets the issue #1469.
try_opt_okmacro to simplify unwrappingResultin anOptioncontexttry_addmacro to improve handling ofi32::checked_add()Result:naivemodule #1445NaiveDate/NaiveDateTime::checked_(add/sub)_daysto returnResultcc @pitdicker