From d7c2fd63b1d33a2c85d85cff7b66a823da680099 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 10 Jan 2025 13:36:04 -0800 Subject: [PATCH] More by-copy methods for Borrowed types --- .../src/provider/pattern/runtime/pattern.rs | 2 +- components/normalizer/src/properties.rs | 2 +- components/properties/src/code_point_map.rs | 2 +- components/properties/src/emoji.rs | 4 ++-- components/properties/src/names.rs | 14 +++++++------- components/timezone/src/windows_tz.rs | 2 +- provider/core/src/request.rs | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/components/datetime/src/provider/pattern/runtime/pattern.rs b/components/datetime/src/provider/pattern/runtime/pattern.rs index 6d7487bc014..aa3a8178732 100644 --- a/components/datetime/src/provider/pattern/runtime/pattern.rs +++ b/components/datetime/src/provider/pattern/runtime/pattern.rs @@ -143,7 +143,7 @@ impl<'data> PatternBorrowed<'data> { metadata: PatternMetadata::DEFAULT, }; - pub(crate) fn as_pattern(&self) -> Pattern<'data> { + pub(crate) fn as_pattern(self) -> Pattern<'data> { Pattern { items: self.items.as_zerovec(), metadata: self.metadata, diff --git a/components/normalizer/src/properties.rs b/components/normalizer/src/properties.rs index 9090b4b14c0..79a8817f501 100644 --- a/components/normalizer/src/properties.rs +++ b/components/normalizer/src/properties.rs @@ -100,7 +100,7 @@ impl CanonicalCompositionBorrowed<'_> { /// assert_eq!(comp.compose('가', 'ᆨ'), Some('각')); // Hangul LVT /// ``` #[inline(always)] - pub fn compose(&self, starter: char, second: char) -> Option { + pub fn compose(self, starter: char, second: char) -> Option { crate::compose( self.canonical_compositions.canonical_compositions.iter(), starter, diff --git a/components/properties/src/code_point_map.rs b/components/properties/src/code_point_map.rs index 78cf594b300..843f9389420 100644 --- a/components/properties/src/code_point_map.rs +++ b/components/properties/src/code_point_map.rs @@ -263,7 +263,7 @@ impl<'a, T: TrieValue> CodePointMapDataBorrowed<'a, T> { impl CodePointMapDataBorrowed<'_, GeneralCategory> { /// TODO - pub fn get_set_for_value_group(&self, value: GeneralCategoryGroup) -> crate::CodePointSetData { + pub fn get_set_for_value_group(self, value: GeneralCategoryGroup) -> crate::CodePointSetData { let matching_gc_ranges = self .iter_ranges() .filter(|cpm_range| (1 << cpm_range.value as u32) & value.0 != 0) diff --git a/components/properties/src/emoji.rs b/components/properties/src/emoji.rs index 712a568b118..7116012e890 100644 --- a/components/properties/src/emoji.rs +++ b/components/properties/src/emoji.rs @@ -120,13 +120,13 @@ impl EmojiSetDataBorrowed<'_> { /// Check if the set contains the code point. #[inline] - pub fn contains(&self, ch: char) -> bool { + pub fn contains(self, ch: char) -> bool { self.set.contains(ch) } /// See [`Self::contains`]. #[inline] - pub fn contains32(&self, cp: u32) -> bool { + pub fn contains32(self, cp: u32) -> bool { self.set.contains32(cp) } } diff --git a/components/properties/src/names.rs b/components/properties/src/names.rs index 70abbd891c2..2dc2bcc8bfd 100644 --- a/components/properties/src/names.rs +++ b/components/properties/src/names.rs @@ -150,7 +150,7 @@ impl PropertyParserBorrowed<'_, T> { /// assert_eq!(lookup.get_strict_u16("UppercaseLetter"), None); /// ``` #[inline] - pub fn get_strict_u16(&self, name: &str) -> Option { + pub fn get_strict_u16(self, name: &str) -> Option { get_strict_u16(self.map, name) } @@ -176,7 +176,7 @@ impl PropertyParserBorrowed<'_, T> { /// assert_eq!(lookup.get_strict("UppercaseLetter"), None); /// ``` #[inline] - pub fn get_strict(&self, name: &str) -> Option { + pub fn get_strict(self, name: &str) -> Option { T::try_from_u32(self.get_strict_u16(name)? as u32).ok() } @@ -206,7 +206,7 @@ impl PropertyParserBorrowed<'_, T> { /// ); /// ``` #[inline] - pub fn get_loose_u16(&self, name: &str) -> Option { + pub fn get_loose_u16(self, name: &str) -> Option { get_loose_u16(self.map, name) } @@ -236,7 +236,7 @@ impl PropertyParserBorrowed<'_, T> { /// ); /// ``` #[inline] - pub fn get_loose(&self, name: &str) -> Option { + pub fn get_loose(self, name: &str) -> Option { T::try_from_u32(self.get_loose_u16(name)? as u32).ok() } } @@ -431,7 +431,7 @@ impl PropertyNamesLongBorrowed<'_, T> { /// ); /// ``` #[inline] - pub fn get(&self, property: T) -> Option<&str> { + pub fn get(self, property: T) -> Option<&str> { self.map.get(property.to_u32()) } } @@ -558,7 +558,7 @@ impl PropertyNamesShortBorrowed<'_, T> { /// assert_eq!(lookup.get(CanonicalCombiningClass::AboveLeft), Some("AL")); /// ``` #[inline] - pub fn get(&self, property: T) -> Option<&str> { + pub fn get(self, property: T) -> Option<&str> { self.map.get(property.to_u32()) } } @@ -603,7 +603,7 @@ impl PropertyNamesShortBorrowed<'_, Script> { /// ); /// ``` #[inline] - pub fn get_locale_script(&self, property: Script) -> Option { + pub fn get_locale_script(self, property: Script) -> Option { let prop = usize::try_from(property.to_u32()).ok()?; self.map.map.get(prop).and_then(|o| o.0) } diff --git a/components/timezone/src/windows_tz.rs b/components/timezone/src/windows_tz.rs index 23a8f506b5f..2ee292520c7 100644 --- a/components/timezone/src/windows_tz.rs +++ b/components/timezone/src/windows_tz.rs @@ -125,7 +125,7 @@ impl WindowsTimeZoneMapperBorrowed<'_> { /// assert_eq!(bcp47_id, Some(TimeZoneBcp47Id(tinystr!(8, "cawnp")))); /// ``` pub fn windows_tz_to_bcp47_id( - &self, + self, windows_tz: &str, region: Option, ) -> Option { diff --git a/provider/core/src/request.rs b/provider/core/src/request.rs index 6d21685a52f..49b9ca48ddd 100644 --- a/provider/core/src/request.rs +++ b/provider/core/src/request.rs @@ -95,7 +95,7 @@ impl<'a> DataIdentifierBorrowed<'a> { } /// Converts this [`DataIdentifierBorrowed`] into a [`DataIdentifierCow<'static>`]. - pub fn into_owned(&self) -> DataIdentifierCow<'static> { + pub fn into_owned(self) -> DataIdentifierCow<'static> { DataIdentifierCow { marker_attributes: Cow::Owned(self.marker_attributes.to_owned()), locale: Cow::Owned(self.locale.clone()), @@ -103,7 +103,7 @@ impl<'a> DataIdentifierBorrowed<'a> { } /// Borrows this [`DataIdentifierBorrowed`] as a [`DataIdentifierCow<'a>`]. - pub fn as_cow(&self) -> DataIdentifierCow<'a> { + pub fn as_cow(self) -> DataIdentifierCow<'a> { DataIdentifierCow { marker_attributes: Cow::Borrowed(self.marker_attributes), locale: Cow::Borrowed(self.locale),