chronotope / chrono

Date and time library for Rust
Other
3.3k stars 523 forks source link

0.5: Make fields of `Parsed` private #1493

Closed pitdicker closed 7 months ago

pitdicker commented 7 months ago

The first commit changes the signature of the Parsed::set_* methods to be usable in a builder pattern, returning ParseResult<&mut Parsed>.

Now that they can be used in a builder pattern, the second commit replaces the parsed! macro in format::parse. That accounts for 250 of the changed lines in this PR.

Then we can change the fields of Parsed to private, and update the tests to no longer set them to invalid values.

The final commit removes some range checks from Parsed::_to that have now become unnecessary.

djc commented 7 months ago

I would also like to just get rid of Parsed::new() in favor of relying on Parsed::default().

pitdicker commented 7 months ago

I would also like to just get rid of Parsed::new() in favor of relying on Parsed::default().

Just realized I only dislike Default::default() because of the name 😆.

pitdicker commented 7 months ago

Sorry for the failing CI: I'll fix it at a better PC later today.

codecov[bot] commented 7 months ago

Codecov Report

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

Project coverage is 94.10%. Comparing base (5982de9) to head (df46038). Report is 13 commits behind head on 0.5.x.

Files Patch % Lines
src/format/parsed.rs 99.15% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## 0.5.x #1493 +/- ## ========================================== + Coverage 93.89% 94.10% +0.21% ========================================== Files 37 37 Lines 17307 17084 -223 ========================================== - Hits 16250 16077 -173 + Misses 1057 1007 -50 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.