-
Notifications
You must be signed in to change notification settings - Fork 183
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 new datetime field set builder #5944
Conversation
pub fn build_time(mut self) -> Result<TimeFieldSet, BuilderError> { | ||
let time_field_set = | ||
TimeFieldSet::T(fieldsets::T::take_from_builder(&mut self, DEFAULT_LENGTH)); | ||
self.check_options_consumed()?; |
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.
praise: clever
@@ -236,6 +238,18 @@ macro_rules! impl_marker_with_options { | |||
$(time_precision: yes_to!(options.time_precision, $timeprecision_yes),)? | |||
} | |||
} | |||
#[allow(unused)] | |||
pub(crate) fn take_from_builder( |
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.
praise: also clever
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.
docs nit: since this is macro generated, docs explaining its behavior would be nice
components/datetime/src/builder.rs
Outdated
pub year_style: Option<YearStyle>, | ||
} | ||
|
||
const DEFAULT_LENGTH: Length = Length::Medium; |
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.
docs nit: should explain why this is here instead of in the macro
|
||
impl FieldSetBuilder { | ||
pub fn build_date(mut self) -> Result<DateFieldSet, BuilderError> { | ||
let date_field_set = match self.date_fields.take() { |
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.
nit: should explain why the time precision is being handled the way it is
|
||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)] | ||
#[non_exhaustive] | ||
pub struct FieldSetBuilder { |
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.
docs nit: should have docs explaining use, and talking qualitatively about which combinations are valid. users should ideally not have to use trial and error to figure out what fields they need to set for their use case
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.
praise: good docs
Part of #5940