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

Refactor internals module part 5 #1433

Merged
merged 5 commits into from
Feb 12, 2024

Conversation

pitdicker
Copy link
Collaborator

These are the simple commits that followed after #1212 but where split out.

  • Split naive::date into separate files to get the same folder structure as naive::time and naive::datetime.
  • Move the NaiveWeek type to its own module. It needs an extra new method because its fields are now private.

Copy link

codecov bot commented Feb 12, 2024

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (3016c30) 91.87% compared to head (bf92d4d) 91.84%.

Files Patch % Lines
src/naive/date/tests.rs 98.30% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1433      +/-   ##
==========================================
- Coverage   91.87%   91.84%   -0.03%     
==========================================
  Files          38       40       +2     
  Lines       17507    17450      -57     
==========================================
- Hits        16084    16027      -57     
  Misses       1423     1423              

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

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

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

So I think we discussed this before, but still not a big fan of the module split as proposed in this PR. All of serde, rustc_serialize and week end up being too small to be worthy of a separate file, IMO. I would suggest moving everything that's not an impl NaiveDate or impl .. for NaiveDate into a types module, maybe?

@@ -1427,7 +1432,7 @@ impl NaiveDate {
/// specified.
#[inline]
pub const fn week(&self, start: Weekday) -> NaiveWeek {
NaiveWeek { date: *self, start }
NaiveWeek::new(*self, start)
Copy link
Member

Choose a reason for hiding this comment

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

This should go before new().

Copy link
Collaborator Author

@pitdicker pitdicker Feb 12, 2024

Choose a reason for hiding this comment

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

Just to make sure: we are looking at NaiveWeek::new and NaiveDate::week. I don't think there is much I can reorder? Or I don't understand your comment.

Copy link
Member

@djc djc Feb 12, 2024

Choose a reason for hiding this comment

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

If week() uses new(), the former should be defined before the latter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I have been using that principle lately.

Copy link
Member

Choose a reason for hiding this comment

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

It's still not looking the way I'd expect it to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is not part of the same impl block or the same type.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, sorry!


#[cfg(test)]
mod tests {
use crate::naive::date::{test_decodable_json, test_encodable_json};
Copy link
Member

Choose a reason for hiding this comment

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

I think test_decodable_json and test_encodable_json should move into tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it okay if I do that as a separate PR for these functions in all four modules (including naive::time, naive::datetime and datetime?

Copy link
Member

Choose a reason for hiding this comment

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

Yup!

@pitdicker
Copy link
Collaborator Author

Yes, the rustc-serialize and serde modules are very small. Shall I keep them in the date/mod.rs file?

And move NaiveWeek and Day into naive/mod.rs?

@djc
Copy link
Member

djc commented Feb 12, 2024

Yes, the rustc-serialize and serde modules are very small. Shall I keep them in the date/mod.rs file?

And move NaiveWeek and Day into naive/mod.rs?

Yes, those sound like nice improvements.

@pitdicker pitdicker merged commit d9d6b63 into chronotope:main Feb 12, 2024
37 checks passed
@pitdicker pitdicker deleted the refactor_internals_5 branch February 12, 2024 15:30
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