-
Notifications
You must be signed in to change notification settings - Fork 546
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
Convert time-related with_*
methods to return Result
#1498
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 0.5.x #1498 +/- ##
==========================================
- Coverage 94.11% 94.04% -0.08%
==========================================
Files 37 37
Lines 17125 17019 -106
==========================================
- Hits 16118 16005 -113
- Misses 1007 1014 +7 ☔ View full report in Codecov by Sentry. |
src/naive/datetime/mod.rs
Outdated
@@ -987,7 +987,7 @@ impl NaiveDateTime { | |||
/// ``` | |||
#[inline] | |||
pub const fn with_minute(&self, min: u32) -> Option<NaiveDateTime> { | |||
Some(NaiveDateTime { time: try_opt!(self.time.with_minute(min)), ..*self }) | |||
Some(NaiveDateTime { time: try_opt!(ok!(self.time.with_minute(min))), ..*self }) |
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.
Why don't we have a try_ok_opt!()
or whatever macro?
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.
They could have use that macro also. It was only there to split up the commits, and replaced in a later commit.
Convert
NaiveTime::{with_hour, with_minute, with_second, with_nanosecond}
andNaiveDateTime::{with_hour, with_minute, with_second, with_nanosecond}
to returnResult
.This turned out to be a refreshingly mechanical change.
I took the opportunity to use
?
in the doctests of the relevant methods.At some point when we are a bit further along we should convert more doctests and regular tests to use
?
.cc @Zomtir