-
Notifications
You must be signed in to change notification settings - Fork 161
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
Implement era formatting #1346
Implement era formatting #1346
Conversation
8 => Second::idx_in_range(&symbol), | ||
9 => TimeZone::idx_in_range(&symbol), | ||
0 => true, // eras | ||
1 => Year::idx_in_range(&symbol), |
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.
Comment: Changing these numbers would break the data file for older ICU4X versions. It's okay to make this change now, but after 1.0, we should add new items to the end, rather than changing the indices for all the old values.
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.
Yeah I'm trying to keep these in order; I think before 1.0 if we're missing symbols we should add them and just have them raise runtime errors
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.
(later) We should discuss options with Zibi. Perhaps we should use TinyStr here?
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.
Perhaps, but we won't be able to postprocess the TinyStr without allocating, so we'd have to use a string-matching ZeroMap, which isn't as cheap
I think I'll move the code to using tinystr as a followup and simultaneously make the data structs borrow |
7f19d25
to
061c48c
Compare
Notice: the branch changed across the force-push!
~ Your Friendly Jira-GitHub PR Checker Bot |
No code changes, just a rebase over the landed dep PR |
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.
lgtm!
return symbols | ||
.0 | ||
.get(idx) | ||
.map(|x| &**x) |
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.
optional (n-b)
: can you use .map(|x| x.as_ref())
here? It's more readable.
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 won't work since we're dereferencing a Cow here, deref coercions don't work through iterators like that
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.
Did you check? I pulled your branch, replaced with x.as_ref()
and it compiles.
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.
.map(AsRef::as_ref)
works as well
Based on #1344
Fixes #1312
This is ready to review,
but still contains commits from #1344 (this PR starts at the commit labeled "add era field parsing" f75ac59)This implements DTF handling for the era symbol
G
and the ability to format eras.