-
Notifications
You must be signed in to change notification settings - Fork 533
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
Conversation
Codecov ReportAttention:
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. |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, sorry!
src/naive/date/serde.rs
Outdated
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::naive::date::{test_decodable_json, test_encodable_json}; |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup!
Yes, the And move |
Yes, those sound like nice improvements. |
7834d6d
to
bf92d4d
Compare
These are the simple commits that followed after #1212 but where split out.
naive::date
into separate files to get the same folder structure asnaive::time
andnaive::datetime
.NaiveWeek
type to its own module. It needs an extranew
method because its fields are now private.