Skip to content

Add RegionDisplayName that directly implements Writeable#7697

Merged
sffc merged 4 commits intounicode-org:mainfrom
sffc:dname-load-single-api
Mar 24, 2026
Merged

Add RegionDisplayName that directly implements Writeable#7697
sffc merged 4 commits intounicode-org:mainfrom
sffc:dname-load-single-api

Conversation

@sffc
Copy link
Member

@sffc sffc commented Feb 25, 2026

#3260 / #3913

Changelog

icu_experimental/displaynames: Add RegionDisplayName for loading a single display name

  • New type: RegionDisplayName

@sffc sffc requested a review from robertbastian February 25, 2026 02:59
@sffc
Copy link
Member Author

sffc commented Feb 25, 2026

Is this roughly what you envision for the one-at-a-time display names API?

@sffc sffc marked this pull request as ready for review February 25, 2026 02:59
@sffc sffc requested a review from snktd as a code owner February 25, 2026 02:59
@sffc
Copy link
Member Author

sffc commented Feb 25, 2026

Discussion: Most/all formatter outputs that implement Writeable borrow from somewhere. With this design, the RegionDisplayName owns its payload. If we add other ways to load RegionDisplayName that borrow instead, we'll need another type.

@sffc sffc requested review from Manishearth and removed request for snktd February 25, 2026 22:06
@sffc sffc changed the title Add RegionDisplayNames::load_long and RegionDisplayName Add RegionDisplayName that directly implements Writeable Feb 25, 2026
}
}

impl writeable::Writeable for RegionDisplayName {
Copy link
Member

Choose a reason for hiding this comment

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

heh, that's interesting

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

Interesting hybrid.

When I was thinking about designs here I figured we would either have free functions returning strings, or a RegionDisplayName type that returns a borrowed string.

I'm not sure if we get much from this being Writeable. I think it's fine, but a bit roundabout? Perhaps we should add an as_str() API as well, and the Writeable impl is there for consistency

@robertbastian
Copy link
Member

Perhaps we should add an as_str() API as well, and the Writeable impl is there for consistency

I would rather not, this boxes us in representation-wise. In the future, we might have things like "Korea (North)", "Korea (South)" that are assembled from parts. Also, LocaleDisplayName won't be able to do as_str() at all.

/// assert_eq!(display_name.to_string(), "United Arab Emirates");
/// ```
functions: [
try_new,
Copy link
Member

Choose a reason for hiding this comment

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

please add all constructors

Copy link
Member

Choose a reason for hiding this comment

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

Not sure which other constructors belong here?

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

I think we should have this in our experimental release.

/// assert_eq!(display_name.to_string(), "United Arab Emirates");
/// ```
functions: [
try_new,
Copy link
Member

Choose a reason for hiding this comment

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

Not sure which other constructors belong here?

Co-authored-by: Gemini CLI <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@sffc sffc merged commit d3d8fee into unicode-org:main Mar 24, 2026
34 of 35 checks passed
@sffc sffc deleted the dname-load-single-api branch March 24, 2026 23:55
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