-
Notifications
You must be signed in to change notification settings - Fork 174
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 YearInfo to CalendarArithmetic (but don't use it yet in any calendar) #4407
Conversation
@@ -32,7 +32,7 @@ use core::num::NonZeroU8; | |||
/// The trait ChineseBased is used by Chinese-based calendars to perform computations shared by such calendar. | |||
/// | |||
/// For an example of how to use this trait, see `impl ChineseBasedWithDataLoading for Chinese` in [`Chinese`]. | |||
pub(crate) trait ChineseBasedWithDataLoading: CalendarArithmetic { | |||
pub(crate) trait ChineseBasedWithDataLoading: Calendar { |
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 had to change, the cyclic dep from ChineseBasedWithDataLoading: CalendarArithmetic
and impl<C: ChineseBasedWithDataLoading> CalendarArithmetic for C
is brittle and rustc seems to not be willing to resolve certain things there.
We don't use it consistently. If we need to split things later in the future we should do that refactoring then.
Argh, I forgot a crucial step here: making CalendarArithmetic work on or at least accepting a YearInfo and now it's somewhat too late: I already got to work on the chinese stuff. This might get bitrotty. |
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.
Looks great
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.
Looks great
This is mostly a scaffolding PR implementing the first few steps of #3933 (comment).
This:
.offset()
to be called with an&impl PrecomputedDataSource<YearInfo>
. An intermediate state of the PR had a separate PrecomputedDataSource associated type as per the original design, but I realized it wasn't necessary and it had a tendency to lead to worse trait resolution issues with the ChineseBased blanket impl()
. A PR actually using this can add the APIs it needsnew_with_lunar_ordinals()
. We weren't maintaining that distinction correctly; and I considered fixing it, but that method only exists in the case of future needs and when those needs come we can easily re-add it and do the proper refactoring.Can be reviewed commit-by-commit if desired, though I'd recommend reviewing the whole PR at once. It's probably sufficient to review calendar_arithmetic.rs and chinese_based.rs.