From b2100586c697bd44b8531f49b807af431547a3da Mon Sep 17 00:00:00 2001 From: "Shane F. Carr" Date: Wed, 25 Oct 2023 15:21:07 -0700 Subject: [PATCH 1/2] Add AuxiliaryKeys::from_subtag --- provider/core/src/request.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/provider/core/src/request.rs b/provider/core/src/request.rs index cb519f297e0..cd2ad314522 100644 --- a/provider/core/src/request.rs +++ b/provider/core/src/request.rs @@ -916,6 +916,25 @@ impl AuxiliaryKeys { } } + /// Creates an [`AuxiliaryKeys`] from a single subtag. + /// + /// # Examples + /// + /// ``` + /// use icu_provider::prelude::*; + /// use icu_locid::extensions::private::subtag; + /// + /// // Single auxiliary key: + /// let a = AuxiliaryKeys::from_subtag(subtag!("abc")); + /// let b = "abc".parse::().unwrap(); + /// assert_eq!(a, b); + /// ``` + pub const fn from_subtag(input: Subtag) -> Self { + Self { + value: AuxiliaryKeysInner::Stack(input.into_tinystr().resize()) + } + } + pub(crate) fn try_from_str(s: &str) -> Result { if !s.is_empty() && s.split(Self::separator()).all(|b| { From 512a6aef385f5da925fdbf0356a071046625506c Mon Sep 17 00:00:00 2001 From: "Shane F. Carr" Date: Wed, 25 Oct 2023 17:22:59 -0700 Subject: [PATCH 2/2] fmt --- provider/core/src/request.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provider/core/src/request.rs b/provider/core/src/request.rs index cd2ad314522..44436a0b2b6 100644 --- a/provider/core/src/request.rs +++ b/provider/core/src/request.rs @@ -931,7 +931,7 @@ impl AuxiliaryKeys { /// ``` pub const fn from_subtag(input: Subtag) -> Self { Self { - value: AuxiliaryKeysInner::Stack(input.into_tinystr().resize()) + value: AuxiliaryKeysInner::Stack(input.into_tinystr().resize()), } }