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

Change pattern representation of fractional seconds; remove obsolete FieldLength variants #5392

Merged
merged 4 commits into from
Aug 22, 2024

Conversation

sffc
Copy link
Member

@sffc sffc commented Aug 19, 2024

#1317

This makes it such that adding or removing fractional second digits involves changing one FieldSymbol, rather than going and mutating the choice of fields in the pattern. Simpler and less error-prone at runtime.

The parsing of "ss.SSS" is moved into the parser, where it belongs, rather than handling it at format time.

@sffc sffc force-pushed the new-fractional-seconds branch 5 times, most recently from 381be5b to 97e5f57 Compare August 19, 2024 21:10
@sffc sffc marked this pull request as ready for review August 19, 2024 21:11
@sffc sffc requested review from Manishearth and removed request for nordzilla August 19, 2024 21:11
@sffc sffc changed the title Change pattern representation of fractional seconds Change pattern representation of fractional seconds; remove obsolete FieldLength variants Aug 19, 2024
@sffc
Copy link
Member Author

sffc commented Aug 19, 2024

There are 2 things going on in this PR: the fractional second change, and removing obsolete FieldLength variants. They are in the same PR because I had earlier thought about supporting fractional seconds via FieldLength, but then I changed to FieldSymbol instead, which ended up being much cleaner. If you want me to cut out the FieldLength changes to their own PR, I can do that upon request.

Manishearth
Manishearth previously approved these changes Aug 20, 2024
#[zerovec::make_ule(DecimalSecondULE)]
#[zerovec::derive(Debug)]
#[allow(clippy::exhaustive_enums)] // used in data struct
pub enum DecimalSecond {
Copy link
Member

Choose a reason for hiding this comment

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

question, n-b: what's the advantage of this over DecimalSecond(u8)?

Copy link
Member Author

Choose a reason for hiding this comment

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

  • Can exhaustively match
  • More niches
  • Encodes the invariants into the type itself

@sffc sffc merged commit 12a5038 into unicode-org:main Aug 22, 2024
28 checks passed
@sffc sffc deleted the new-fractional-seconds branch August 22, 2024 21:46
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.

3 participants