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 NaiveDate::{from_yo|from_isoywd} to return Result #1460

Merged
merged 2 commits into from
Feb 28, 2024

Conversation

pitdicker
Copy link
Collaborator

@pitdicker pitdicker commented Feb 25, 2024

cc @Zomtir. I would like to depend on these methods when working on the Parsed type, and you don't seem to have started on them yet.

@pitdicker pitdicker changed the title Convert NaiveDate::{from_yo|from_isoywd} to return Result` Convert NaiveDate::{from_yo|from_isoywd} to return Result Feb 25, 2024
Copy link

codecov bot commented Feb 25, 2024

Codecov Report

Attention: Patch coverage is 98.93617% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 94.33%. Comparing base (f0e6695) to head (03727e8).

Files Patch % Lines
src/naive/date/mod.rs 97.67% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            0.5.x    #1460   +/-   ##
=======================================
  Coverage   94.33%   94.33%           
=======================================
  Files          37       37           
  Lines       17004    17011    +7     
=======================================
+ Hits        16040    16047    +7     
  Misses        964      964           

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

@pitdicker
Copy link
Collaborator Author

Simplified from_isoywd a bit and made that into a commit that can apply to the main branch.

Comment on lines 267 to 271
if week == 0 || week > 53 {
return Err(Error::InvalidArgument);
} else {
return Err(Error::DoesNotExist);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, would suggest the following:

return Err(match week == 0 || week > 53 {
    true => Error::InvalidArgument,
    false => Error::DoesNotExist,
});

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the next time just say 'Use match'. I should know by now 😆.

@pitdicker pitdicker force-pushed the from_yo_result branch 2 times, most recently from af0c228 to d60fbaf Compare February 27, 2024 14:41
@pitdicker
Copy link
Collaborator Author

I'll keep this PR open a little longer until we have a new merge of main with the 0.5.x branch.

@pitdicker pitdicker merged commit 6fd71d3 into chronotope:0.5.x Feb 28, 2024
35 checks passed
@pitdicker pitdicker deleted the from_yo_result branch February 28, 2024 13:00
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.

3 participants