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

Should NeoFormatter and TypedNeoFormatter have default generics? #5687

Open
sffc opened this issue Oct 15, 2024 · 4 comments
Open

Should NeoFormatter and TypedNeoFormatter have default generics? #5687

sffc opened this issue Oct 15, 2024 · 4 comments
Labels
discuss Discuss at a future ICU4X-SC meeting

Comments

@sffc
Copy link
Member

sffc commented Oct 15, 2024

Currently if you want a time formatter you need to explicitly set the calendar type to NeverCalendar / ().

This raises the general question, should they have default generics?

The time formatter specific concern can also be addressed by

  1. Make a type alias such as pub type TimeFormatter
  2. Make format_time imply this bound

@Manishearth @robertbastian

@sffc sffc added the discuss-priority Discuss at the next ICU4X meeting label Oct 15, 2024
@sffc sffc added this to the ICU4X 2.0 ⟨P1⟩ milestone Oct 15, 2024
@Manishearth
Copy link
Member

I don't really think there's a sensible "default" here. I think TimeFormatter is fine. I also think adding the bound may work, though it would be nice if DateTimeFormatter could format_time too.

@sffc
Copy link
Member Author

sffc commented Oct 15, 2024

This currently works:

TypedFormatter::try_new(
  locale,
  fieldset::YMD::with_length(Medium)
)
.format(Date::try_new_gregorian_date(...))

This currently requires an explicit NeverCalendar:

TypedFormatter::<NeverCalendar, _>::try_new(
  locale,
  fieldset::HM::with_length(Medium)
)
.format(Time::try_new(...))

If we had format_time (#5269 (comment)), the type inference should work because the function would be defined on Formatter<NeverCalendar>

TypedFormatter::try_new(
  locale,
  fieldset::HM::with_length(Medium)
)
.format_time(Time::try_new(...))

@sffc
Copy link
Member Author

sffc commented Oct 15, 2024

What would pub type TimeFormatter map to?

pub type TimeFormatter<FSet> = TypedFormatter<NeverCalendar, FSet>
pub type TimeFormatter<FSet> = Formatter<FSet>
pub type TimeFormatter = TypedFormatter<NeverCalendar, TimeSkeleton>

@sffc
Copy link
Member Author

sffc commented Oct 15, 2024

I don't consider this a 2.0-beta blocker.

@sffc sffc added discuss Discuss at a future ICU4X-SC meeting and removed discuss-priority Discuss at the next ICU4X meeting labels Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Discuss at a future ICU4X-SC meeting
Projects
None yet
Development

No branches or pull requests

2 participants