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

Make ZoneVariant a closed, non-exhaustive enum #5760

Merged
merged 5 commits into from
Nov 4, 2024

Conversation

robertbastian
Copy link
Member

Manishearth
Manishearth previously approved these changes Oct 31, 2024
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.

much nicer!

@robertbastian
Copy link
Member Author

/automerge

Manishearth
Manishearth previously approved these changes Nov 1, 2024
match zone_variant {
ZoneVariant::Standard => &locations.pattern_standard,
ZoneVariant::Daylight => &locations.pattern_daylight,
_ => unreachable!(),
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Annotate here and elsewhere that this is unreachable due to the tilde dependency

Some(icu_timezone::ZoneVariant::Daylight) => "dt",
Some(icu_timezone::ZoneVariant::Standard) => "st",
_ => return None,
});
Some(())
}

/// Sets the `zone_variant` field to "standard" time, which may or may
/// not correspond to a display name with "Standard" in its name.
#[diplomat::rust_link(icu::timezone::ZoneVariant::standard, FnInStruct)]
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Update the rust link

@@ -211,17 +211,19 @@ pub mod ffi {
/// Sets the `zone_variant` field from a string.
///
/// Returns null if the string is not a valid zone variant.
#[diplomat::rust_link(icu::timezone::ZoneVariant, Struct, compact)]
#[diplomat::rust_link(icu::timezone::ZoneVariant, Enum, compact)]
#[diplomat::rust_link(icu::timezone::ZoneVariant::from_str, FnInStruct, hidden)]
pub fn try_set_zone_variant(&mut self, id: &DiplomatStr) -> Option<()> {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Delete these old functions. New variants will get new functions.

@robertbastian robertbastian merged commit d4b636f into unicode-org:main Nov 4, 2024
28 checks passed
@robertbastian robertbastian deleted the close branch November 4, 2024 07:30
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