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

Convert time-related with_* methods to return Result #1498

Merged
merged 8 commits into from
Mar 11, 2024

Conversation

pitdicker
Copy link
Collaborator

Convert NaiveTime::{with_hour, with_minute, with_second, with_nanosecond} and NaiveDateTime::{with_hour, with_minute, with_second, with_nanosecond} to return Result.
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

Copy link

codecov bot commented Mar 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.04%. Comparing base (b01933e) to head (21ad808).
Report is 13 commits behind head on 0.5.x.

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.
📢 Have feedback on the report? Share it here.

@@ -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 })
Copy link
Member

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?

Copy link
Collaborator Author

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.

@pitdicker pitdicker merged commit b9c13bb into chronotope:0.5.x Mar 11, 2024
35 checks passed
@pitdicker pitdicker deleted the naivetime_with branch March 11, 2024 13:16
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