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

Add range checks to Parsed::set and hide fields in docs #1465

Merged
merged 3 commits into from Mar 6, 2024

Conversation

pitdicker
Copy link
Collaborator

@pitdicker pitdicker commented Feb 27, 2024

This does not remove the range checks from the Parsed::to_* methods, because as long as the fields are public they can be set to an out of range value. Something to do on the 0.5.x branch.

src/format/parsed.rs Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 27, 2024

Codecov Report

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

Project coverage is 91.93%. Comparing base (e292d9b) to head (23a65df).
Report is 15 commits behind head on main.

❗ Current head 23a65df differs from pull request most recent head 15f7e62. Consider uploading reports for the commit 15f7e62 to get more accurate results

Files Patch % Lines
src/format/parsed.rs 70.46% 57 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1465      +/-   ##
==========================================
- Coverage   92.16%   91.93%   -0.24%     
==========================================
  Files          40       40              
  Lines       18052    18218     +166     
==========================================
+ Hits        16637    16748     +111     
- Misses       1415     1470      +55     

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

@pitdicker
Copy link
Collaborator Author

@djc When you have time, can you look at the direction of the documentation in the last commit? Then I'll merge squash it into the right commit.

I would like to start building on top of this PR 😄.

@@ -575,6 +584,175 @@ impl Parsed {
set_if_consistent(&mut self.offset, i32::try_from(value).map_err(|_| OUT_OF_RANGE)?)
}

/// Get the `year` field if set.
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add these below the to_* methods, since they're pretty trivial?

@pitdicker pitdicker merged commit 90dbd75 into chronotope:main Mar 6, 2024
32 of 33 checks passed
@pitdicker pitdicker deleted the parsed_range_checks branch March 6, 2024 13:01
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.

None yet

2 participants