Skip to content

Commit e826a2e

Browse files
authored
Add AuxiliaryKeys::from_subtag (#4223)
We still have #3632 open to continue bikeshedding on API design.
1 parent 2582efb commit e826a2e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

provider/core/src/request.rs

+19
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,25 @@ impl AuxiliaryKeys {
916916
}
917917
}
918918

919+
/// Creates an [`AuxiliaryKeys`] from a single subtag.
920+
///
921+
/// # Examples
922+
///
923+
/// ```
924+
/// use icu_provider::prelude::*;
925+
/// use icu_locid::extensions::private::subtag;
926+
///
927+
/// // Single auxiliary key:
928+
/// let a = AuxiliaryKeys::from_subtag(subtag!("abc"));
929+
/// let b = "abc".parse::<AuxiliaryKeys>().unwrap();
930+
/// assert_eq!(a, b);
931+
/// ```
932+
pub const fn from_subtag(input: Subtag) -> Self {
933+
Self {
934+
value: AuxiliaryKeysInner::Stack(input.into_tinystr().resize()),
935+
}
936+
}
937+
919938
pub(crate) fn try_from_str(s: &str) -> Result<Self, DataError> {
920939
if !s.is_empty()
921940
&& s.split(Self::separator()).all(|b| {

0 commit comments

Comments
 (0)