From a73dcae5a2b4ae3a0603dc242db2fa60ffa74cef Mon Sep 17 00:00:00 2001 From: Robert Bastian Date: Mon, 26 Jun 2023 11:31:42 +0200 Subject: [PATCH] iter --- components/properties/src/exemplar_chars.rs | 20 +- components/properties/src/maps.rs | 2 +- components/properties/src/props.rs | 244 ++++++++++---------- components/properties/src/sets.rs | 2 +- 4 files changed, 141 insertions(+), 127 deletions(-) diff --git a/components/properties/src/exemplar_chars.rs b/components/properties/src/exemplar_chars.rs index e7da1f44111..e182c3479ea 100644 --- a/components/properties/src/exemplar_chars.rs +++ b/components/properties/src/exemplar_chars.rs @@ -20,7 +20,7 @@ //! use icu::properties::exemplar_chars; //! //! let locale = locale!("en-001").into(); -//! let data = exemplar_chars::exemplars_main(&locale); +//! let data = exemplar_chars::exemplars_main(&locale).expect("locale should be present"); //! let exemplars_main = data.as_borrowed(); //! //! assert!(exemplars_main.contains_char('a')); @@ -46,9 +46,6 @@ macro_rules! make_exemplar_chars_unicode_set_property { $vis2:vis fn $constname:ident(); ) => { #[doc = concat!("[`", stringify!($constname), "()`] with a runtime data provider argument.")] - /// - /// Note that this will return an owned version of the data. Functionality is available on - /// the borrowed version, accessible through `.as_borrowed()`. $vis fn $funcname( provider: &(impl DataProvider<$keyed_data_marker> + ?Sized), locale: &DataLocale, @@ -96,7 +93,8 @@ make_exemplar_chars_unicode_set_property!( /// use icu::locid::locale; /// use icu::properties::exemplar_chars; /// - /// let data = exemplar_chars::exemplars_main(&locale!("en").into()); + /// let data = exemplar_chars::exemplars_main(&locale!("en").into()) + /// .expect("locale should be present"); /// let exemplars_main = data.as_borrowed(); /// /// assert!(exemplars_main.contains_char('a')); @@ -124,7 +122,8 @@ make_exemplar_chars_unicode_set_property!( /// use icu::properties::exemplar_chars; /// /// let data = - /// exemplar_chars::exemplars_auxiliary(&locale!("en").into()); + /// exemplar_chars::exemplars_auxiliary(&locale!("en").into()) + /// .expect("locale should be present"); /// let exemplars_auxiliary = data.as_borrowed(); /// /// assert!(!exemplars_auxiliary.contains_char('a')); @@ -152,7 +151,8 @@ make_exemplar_chars_unicode_set_property!( /// use icu::properties::exemplar_chars; /// /// let data = - /// exemplar_chars::exemplars_punctuation(&locale!("en").into()); + /// exemplar_chars::exemplars_punctuation(&locale!("en").into()) + /// .expect("locale should be present"); /// let exemplars_punctuation = data.as_borrowed(); /// /// assert!(!exemplars_punctuation.contains_char('0')); @@ -181,7 +181,8 @@ make_exemplar_chars_unicode_set_property!( /// use icu::properties::exemplar_chars; /// /// let data = - /// exemplar_chars::exemplars_numbers(&locale!("en").into()); + /// exemplar_chars::exemplars_numbers(&locale!("en").into()) + /// .expect("locale should be present"); /// let exemplars_numbers = data.as_borrowed(); /// /// assert!(exemplars_numbers.contains_char('0')); @@ -210,7 +211,8 @@ make_exemplar_chars_unicode_set_property!( /// use icu::properties::exemplar_chars; /// /// let data = - /// exemplar_chars::exemplars_index(&locale!("en").into()); + /// exemplar_chars::exemplars_index(&locale!("en").into()) + /// .expect("locale should be present"); /// let exemplars_index = data.as_borrowed(); /// /// assert!(!exemplars_index.contains_char('a')); diff --git a/components/properties/src/maps.rs b/components/properties/src/maps.rs index 03351014a05..a8de2f73481 100644 --- a/components/properties/src/maps.rs +++ b/components/properties/src/maps.rs @@ -310,7 +310,7 @@ macro_rules! make_map_property { ) => { #[doc = concat!("[`", stringify!($constname), "()`] with a runtime data provider argument.")] /// - /// Note that this will return an owned version of the data. Functionality is available on + /// Note that this will return an owned version of the data. Functionality is available on /// the borrowed version, accessible through `.as_borrowed()`. $vis fn $name( provider: &(impl DataProvider<$keyed_data_marker> + ?Sized) diff --git a/components/properties/src/props.rs b/components/properties/src/props.rs index 4cc1de1ac8c..a3eb3afcb72 100644 --- a/components/properties/src/props.rs +++ b/components/properties/src/props.rs @@ -44,8 +44,8 @@ impl DataMarker for ErasedNameToEnumMapV1Marker { /// use icu::properties::GeneralCategory; /// /// let lookup = -/// GeneralCategory::get_name_to_enum_mapper(&icu_testdata::unstable()) -/// .expect("The data should be valid"); +/// GeneralCategory::name_to_enum_mapper() +/// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!( @@ -128,8 +128,8 @@ impl PropertyValueNameToEnumMapperBorrowed<'_, T> { /// use icu_properties::GeneralCategory; /// /// let lookup = - /// GeneralCategory::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// GeneralCategory::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!( /// lookup.get_strict_u16("Lu"), @@ -156,8 +156,8 @@ impl PropertyValueNameToEnumMapperBorrowed<'_, T> { /// use icu_properties::GeneralCategory; /// /// let lookup = - /// GeneralCategory::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// GeneralCategory::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!( /// lookup.get_strict("Lu"), @@ -185,8 +185,8 @@ impl PropertyValueNameToEnumMapperBorrowed<'_, T> { /// use icu_properties::GeneralCategory; /// /// let lookup = - /// GeneralCategory::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// GeneralCategory::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!( /// lookup.get_loose_u16("Lu"), @@ -217,8 +217,8 @@ impl PropertyValueNameToEnumMapperBorrowed<'_, T> { /// use icu_properties::GeneralCategory; /// /// let lookup = - /// GeneralCategory::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// GeneralCategory::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!( /// lookup.get_loose("Lu"), @@ -279,10 +279,9 @@ impl DataMarker for ErasedEnumToValueNameSparseMapV1Marker { /// ``` /// use icu::properties::CanonicalCombiningClass; /// -/// let lookup = CanonicalCombiningClass::get_enum_to_long_name_mapper( -/// &icu_testdata::unstable(), +/// let lookup = CanonicalCombiningClass::enum_to_long_name_mapper( /// ) -/// .expect("The data should be valid"); +/// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!( /// lookup.get(CanonicalCombiningClass::KanaVoicing), @@ -343,10 +342,9 @@ impl PropertyEnumToValueNameSparseMapperBorrowed<'_, T> { /// ```rust /// use icu::properties::CanonicalCombiningClass; /// - /// let lookup = CanonicalCombiningClass::get_enum_to_long_name_mapper( - /// &icu_testdata::unstable(), + /// let lookup = CanonicalCombiningClass::enum_to_long_name_mapper( /// ) - /// .expect("The data should be valid"); + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!( /// lookup.get(CanonicalCombiningClass::KanaVoicing), @@ -387,10 +385,9 @@ impl DataMarker for ErasedEnumToValueNameLinearMapV1Marker { /// ``` /// use icu::properties::GeneralCategory; /// -/// let lookup = GeneralCategory::get_enum_to_long_name_mapper( -/// &icu_testdata::unstable(), +/// let lookup = GeneralCategory::enum_to_long_name_mapper( /// ) -/// .expect("The data should be valid"); +/// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!( /// lookup.get(GeneralCategory::UppercaseLetter), @@ -451,10 +448,9 @@ impl PropertyEnumToValueNameLinearMapperBorrowed<'_, T> { /// ```rust /// use icu::properties::GeneralCategory; /// - /// let lookup = GeneralCategory::get_enum_to_short_name_mapper( - /// &icu_testdata::unstable(), + /// let lookup = GeneralCategory::enum_to_short_name_mapper( /// ) - /// .expect("The data should be valid"); + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(GeneralCategory::UppercaseLetter), Some("Lu")); /// assert_eq!(lookup.get(GeneralCategory::DashPunctuation), Some("Pd")); @@ -489,8 +485,8 @@ impl DataMarker for ErasedEnumToValueNameLinearTiny4MapV1Marker { /// use tinystr::tinystr; /// /// let lookup = -/// Script::get_enum_to_short_name_mapper(&icu_testdata::unstable()) -/// .expect("The data should be valid"); +/// Script::enum_to_short_name_mapper() +/// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(Script::Brahmi), Some(tinystr!(4, "Brah"))); /// assert_eq!(lookup.get(Script::Hangul), Some(tinystr!(4, "Hang"))); @@ -547,8 +543,8 @@ impl PropertyEnumToValueNameLinearTiny4MapperBorrowed<'_, T> { /// use tinystr::tinystr; /// /// let lookup = - /// Script::get_enum_to_short_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// Script::enum_to_short_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(Script::Brahmi), Some(tinystr!(4, "Brah"))); /// assert_eq!(lookup.get(Script::Hangul), Some(tinystr!(4, "Hang"))); @@ -565,18 +561,24 @@ macro_rules! impl_value_getter { markers: $marker_n2e:ident$(, $marker_e2sn:ident, $marker_e2ln:ident)?; impl $ty:ident { $(#[$attr_n2e:meta])* - $vis_n2e:vis fn $name_n2e:ident(); + $vis_n2e:vis fn $name_n2e:ident() / $cname_n2e:ident(); $( $(#[$attr_e2sn:meta])* - $vis_e2sn:vis fn $name_e2sn:ident() -> $mapper_e2sn:ident; + $vis_e2sn:vis fn $name_e2sn:ident() / $cname_e2sn:ident() -> $mapper_e2sn:ident; $(#[$attr_e2ln:meta])* - $vis_e2ln:vis fn $name_e2ln:ident()-> $mapper_e2ln:ident; + $vis_e2ln:vis fn $name_e2ln:ident() / $cname_e2ln:ident() -> $mapper_e2ln:ident; )? } ) => { impl $ty { $(#[$attr_n2e])* + $vis_n2e fn $cname_n2e() -> Result, DataError> { + DataProvider::<$marker_n2e>::load(&crate::provider::Baked, Default::default()) + .and_then(DataResponse::take_payload).map(PropertyValueNameToEnumMapper::from_data) + } + + #[doc = concat!("[`", stringify!($cname_n2e), "()`] with a runtime data provider argument.")] $vis_n2e fn $name_n2e( provider: &(impl DataProvider<$marker_n2e> + ?Sized) ) -> Result, PropertiesError> { @@ -585,6 +587,12 @@ macro_rules! impl_value_getter { $( $(#[$attr_e2sn])* + $vis_e2sn fn $cname_e2sn() -> Result<$mapper_e2sn<$ty>, DataError> { + DataProvider::<$marker_e2sn>::load(&crate::provider::Baked, Default::default()) + .and_then(DataResponse::take_payload).map($mapper_e2sn::from_data) + } + + #[doc = concat!("[`", stringify!($cname_e2sn), "()`] with a runtime data provider argument.")] $vis_e2sn fn $name_e2sn( provider: &(impl DataProvider<$marker_e2sn> + ?Sized) ) -> Result<$mapper_e2sn<$ty>, PropertiesError> { @@ -592,6 +600,12 @@ macro_rules! impl_value_getter { } $(#[$attr_e2ln])* + $vis_e2ln fn $cname_e2ln() -> Result<$mapper_e2ln<$ty>, DataError> { + DataProvider::<$marker_e2ln>::load(&crate::provider::Baked, Default::default()) + .and_then(DataResponse::take_payload).map($mapper_e2ln::from_data) + } + + #[doc = concat!("[`", stringify!($cname_e2ln), "()`] with a runtime data provider argument.")] $vis_e2ln fn $name_e2ln( provider: &(impl DataProvider<$marker_e2ln> + ?Sized) ) -> Result<$mapper_e2ln<$ty>, PropertiesError> { @@ -677,8 +691,8 @@ impl_value_getter! { /// ``` /// use icu::properties::BidiClass; /// - /// let lookup = BidiClass::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = BidiClass::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!(lookup.get_strict("AN"), Some(BidiClass::ArabicNumber)); @@ -693,7 +707,7 @@ impl_value_getter! { /// // fake property /// assert_eq!(lookup.get_strict("Upside_Down_Vertical_Backwards_Mirrored"), None); /// ``` - pub fn get_name_to_enum_mapper(); + pub fn get_name_to_enum_mapper() / name_to_enum_mapper(); /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up short names /// for values of the `Bidi_Class` enumerated property /// @@ -702,13 +716,13 @@ impl_value_getter! { /// ``` /// use icu::properties::BidiClass; /// - /// let lookup = BidiClass::get_enum_to_short_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = BidiClass::enum_to_short_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(BidiClass::ArabicNumber), Some("AN")); /// assert_eq!(lookup.get(BidiClass::NonspacingMark), Some("NSM")); /// ``` - pub fn get_enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_short_name_mapper() / enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up long names /// for values of the `Bidi_Class` enumerated property /// @@ -717,13 +731,13 @@ impl_value_getter! { /// ``` /// use icu::properties::BidiClass; /// - /// let lookup = BidiClass::get_enum_to_long_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = BidiClass::enum_to_long_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(BidiClass::ArabicNumber), Some("Arabic_Number")); /// assert_eq!(lookup.get(BidiClass::NonspacingMark), Some("Nonspacing_Mark")); /// ``` - pub fn get_enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_long_name_mapper() / enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; } } @@ -823,8 +837,8 @@ impl_value_getter! { /// ``` /// use icu::properties::GeneralCategory; /// - /// let lookup = GeneralCategory::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = GeneralCategory::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!(lookup.get_strict("Lu"), Some(GeneralCategory::UppercaseLetter)); @@ -839,7 +853,7 @@ impl_value_getter! { /// // fake property /// assert_eq!(lookup.get_loose("Animated_Gif"), None); /// ``` - pub fn get_name_to_enum_mapper(); + pub fn get_name_to_enum_mapper() / name_to_enum_mapper(); /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up short names /// for values of the `General_Category` enumerated property /// @@ -848,13 +862,13 @@ impl_value_getter! { /// ``` /// use icu::properties::GeneralCategory; /// - /// let lookup = GeneralCategory::get_enum_to_short_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = GeneralCategory::enum_to_short_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(GeneralCategory::UppercaseLetter), Some("Lu")); /// assert_eq!(lookup.get(GeneralCategory::DashPunctuation), Some("Pd")); /// ``` - pub fn get_enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_short_name_mapper() / enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up long names /// for values of the `General_Category` enumerated property /// @@ -863,13 +877,13 @@ impl_value_getter! { /// ``` /// use icu::properties::GeneralCategory; /// - /// let lookup = GeneralCategory::get_enum_to_long_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = GeneralCategory::enum_to_long_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(GeneralCategory::UppercaseLetter), Some("Uppercase_Letter")); /// assert_eq!(lookup.get(GeneralCategory::DashPunctuation), Some("Dash_Punctuation")); /// ``` - pub fn get_enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_long_name_mapper() / enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; } } @@ -1027,9 +1041,7 @@ impl GeneralCategoryGroup { /// use icu::properties::{maps, GeneralCategory, GeneralCategoryGroup}; /// use icu_collections::codepointtrie::CodePointTrie; /// - /// let data = maps::load_general_category(&icu_testdata::unstable()) - /// .expect("The data should be valid"); - /// let gc = data.as_borrowed(); + /// let gc = maps::general_category(); /// /// assert_eq!(gc.get('A'), GeneralCategory::UppercaseLetter); /// assert!(GeneralCategoryGroup::CasedLetter.contains(gc.get('A'))); @@ -1178,8 +1190,8 @@ impl_value_getter! { /// ``` /// use icu::properties::GeneralCategoryGroup; /// - /// let lookup = GeneralCategoryGroup::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = GeneralCategoryGroup::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!(lookup.get_strict("L"), Some(GeneralCategoryGroup::Letter)); @@ -1200,7 +1212,7 @@ impl_value_getter! { /// // fake property /// assert_eq!(lookup.get_strict("EverythingLol"), None); /// ``` - pub fn get_name_to_enum_mapper(); + pub fn get_name_to_enum_mapper() / name_to_enum_mapper(); } } @@ -1420,8 +1432,8 @@ impl_value_getter! { /// ``` /// use icu::properties::Script; /// - /// let lookup = Script::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = Script::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!(lookup.get_strict("Brah"), Some(Script::Brahmi)); @@ -1436,7 +1448,7 @@ impl_value_getter! { /// // fake property /// assert_eq!(lookup.get_strict("Linear_Z"), None); /// ``` - pub fn get_name_to_enum_mapper(); + pub fn get_name_to_enum_mapper() / name_to_enum_mapper(); /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up short names /// for values of the `Script` enumerated property /// @@ -1446,13 +1458,13 @@ impl_value_getter! { /// use icu::properties::Script; /// use tinystr::tinystr; /// - /// let lookup = Script::get_enum_to_short_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = Script::enum_to_short_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(Script::Brahmi), Some(tinystr!(4, "Brah"))); /// assert_eq!(lookup.get(Script::Hangul), Some(tinystr!(4, "Hang"))); /// ``` - pub fn get_enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearTiny4Mapper; + pub fn get_enum_to_short_name_mapper() / enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearTiny4Mapper; /// Return a [`PropertyEnumToValueNameLinearTiny4Mapper`], capable of looking up long names /// for values of the `Script` enumerated property /// @@ -1461,13 +1473,13 @@ impl_value_getter! { /// ``` /// use icu::properties::Script; /// - /// let lookup = Script::get_enum_to_long_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = Script::enum_to_long_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(Script::Brahmi), Some("Brahmi")); /// assert_eq!(lookup.get(Script::Hangul), Some("Hangul")); /// ``` - pub fn get_enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_long_name_mapper() / enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; } } @@ -1508,8 +1520,8 @@ impl_value_getter! { /// ``` /// use icu::properties::EastAsianWidth; /// - /// let lookup = EastAsianWidth::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = EastAsianWidth::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!(lookup.get_strict("N"), Some(EastAsianWidth::Neutral)); @@ -1524,7 +1536,7 @@ impl_value_getter! { /// // fake property /// assert_eq!(lookup.get_strict("TwoPointFiveWidth"), None); /// ``` - pub fn get_name_to_enum_mapper(); + pub fn get_name_to_enum_mapper() / name_to_enum_mapper(); /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up short names /// for values of the `East_Asian_Width` enumerated property /// @@ -1533,13 +1545,13 @@ impl_value_getter! { /// ``` /// use icu::properties::EastAsianWidth; /// - /// let lookup = EastAsianWidth::get_enum_to_short_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = EastAsianWidth::enum_to_short_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(EastAsianWidth::Neutral), Some("N")); /// assert_eq!(lookup.get(EastAsianWidth::Halfwidth), Some("H")); /// ``` - pub fn get_enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_short_name_mapper() / enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up long names /// for values of the `East_Asian_Width` enumerated property /// @@ -1548,13 +1560,13 @@ impl_value_getter! { /// ``` /// use icu::properties::EastAsianWidth; /// - /// let lookup = EastAsianWidth::get_enum_to_long_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = EastAsianWidth::enum_to_long_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(EastAsianWidth::Neutral), Some("Neutral")); /// assert_eq!(lookup.get(EastAsianWidth::Halfwidth), Some("Halfwidth")); /// ``` - pub fn get_enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_long_name_mapper() / enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; } } @@ -1632,8 +1644,8 @@ impl_value_getter! { /// ``` /// use icu::properties::LineBreak; /// - /// let lookup = LineBreak::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = LineBreak::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!(lookup.get_strict("BK"), Some(LineBreak::MandatoryBreak)); @@ -1648,7 +1660,7 @@ impl_value_getter! { /// // fake property /// assert_eq!(lookup.get_strict("Stochastic_Break"), None); /// ``` - pub fn get_name_to_enum_mapper(); + pub fn get_name_to_enum_mapper() / name_to_enum_mapper(); /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up short names /// for values of the `Line_Break` enumerated property /// @@ -1657,13 +1669,13 @@ impl_value_getter! { /// ``` /// use icu::properties::LineBreak; /// - /// let lookup = LineBreak::get_enum_to_short_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = LineBreak::enum_to_short_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(LineBreak::MandatoryBreak), Some("BK")); /// assert_eq!(lookup.get(LineBreak::Alphabetic), Some("AL")); /// ``` - pub fn get_enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_short_name_mapper() / enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up long names /// for values of the `Line_Break` enumerated property /// @@ -1672,13 +1684,13 @@ impl_value_getter! { /// ``` /// use icu::properties::LineBreak; /// - /// let lookup = LineBreak::get_enum_to_long_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = LineBreak::enum_to_long_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(LineBreak::MandatoryBreak), Some("Mandatory_Break")); /// assert_eq!(lookup.get(LineBreak::Alphabetic), Some("Alphabetic")); /// ``` - pub fn get_enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_long_name_mapper() / enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; } } @@ -1736,8 +1748,8 @@ impl_value_getter! { /// ``` /// use icu::properties::GraphemeClusterBreak; /// - /// let lookup = GraphemeClusterBreak::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = GraphemeClusterBreak::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!(lookup.get_strict("EX"), Some(GraphemeClusterBreak::Extend)); @@ -1752,7 +1764,7 @@ impl_value_getter! { /// // fake property /// assert_eq!(lookup.get_strict("Regional_Indicator_Two_Point_Oh"), None); /// ``` - pub fn get_name_to_enum_mapper(); + pub fn get_name_to_enum_mapper() / name_to_enum_mapper(); /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up short names /// for values of the `Grapheme_Cluster_Break` enumerated property /// @@ -1761,13 +1773,13 @@ impl_value_getter! { /// ``` /// use icu::properties::GraphemeClusterBreak; /// - /// let lookup = GraphemeClusterBreak::get_enum_to_short_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = GraphemeClusterBreak::enum_to_short_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(GraphemeClusterBreak::Extend), Some("EX")); /// assert_eq!(lookup.get(GraphemeClusterBreak::RegionalIndicator), Some("RI")); /// ``` - pub fn get_enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_short_name_mapper() / enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up long names /// for values of the `Grapheme_Cluster_Break` enumerated property /// @@ -1776,13 +1788,13 @@ impl_value_getter! { /// ``` /// use icu::properties::GraphemeClusterBreak; /// - /// let lookup = GraphemeClusterBreak::get_enum_to_long_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = GraphemeClusterBreak::enum_to_long_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(GraphemeClusterBreak::Extend), Some("Extend")); /// assert_eq!(lookup.get(GraphemeClusterBreak::RegionalIndicator), Some("Regional_Indicator")); /// ``` - pub fn get_enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_long_name_mapper() / enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; } } @@ -1845,8 +1857,8 @@ impl_value_getter! { /// ``` /// use icu::properties::WordBreak; /// - /// let lookup = WordBreak::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = WordBreak::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!(lookup.get_strict("KA"), Some(WordBreak::Katakana)); @@ -1861,7 +1873,7 @@ impl_value_getter! { /// // fake property /// assert_eq!(lookup.get_strict("Quadruple_Quote"), None); /// ``` - pub fn get_name_to_enum_mapper(); + pub fn get_name_to_enum_mapper() / name_to_enum_mapper(); /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up short names /// for values of the `Word_Break` enumerated property /// @@ -1870,13 +1882,13 @@ impl_value_getter! { /// ``` /// use icu::properties::WordBreak; /// - /// let lookup = WordBreak::get_enum_to_short_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = WordBreak::enum_to_short_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(WordBreak::Katakana), Some("KA")); /// assert_eq!(lookup.get(WordBreak::ALetter), Some("LE")); /// ``` - pub fn get_enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_short_name_mapper() / enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up long names /// for values of the `Word_Break` enumerated property /// @@ -1885,13 +1897,13 @@ impl_value_getter! { /// ``` /// use icu::properties::WordBreak; /// - /// let lookup = WordBreak::get_enum_to_long_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = WordBreak::enum_to_long_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(WordBreak::Katakana), Some("Katakana")); /// assert_eq!(lookup.get(WordBreak::ALetter), Some("ALetter")); /// ``` - pub fn get_enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_long_name_mapper() / enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; } } @@ -1941,8 +1953,8 @@ impl_value_getter! { /// ``` /// use icu::properties::SentenceBreak; /// - /// let lookup = SentenceBreak::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = SentenceBreak::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!(lookup.get_strict("FO"), Some(SentenceBreak::Format)); @@ -1957,7 +1969,7 @@ impl_value_getter! { /// // fake property /// assert_eq!(lookup.get_strict("Fixer_Upper"), None); /// ``` - pub fn get_name_to_enum_mapper(); + pub fn get_name_to_enum_mapper() / name_to_enum_mapper(); /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up short names /// for values of the `Sentence_Break` enumerated property /// @@ -1966,13 +1978,13 @@ impl_value_getter! { /// ``` /// use icu::properties::SentenceBreak; /// - /// let lookup = SentenceBreak::get_enum_to_short_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = SentenceBreak::enum_to_short_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(SentenceBreak::Format), Some("FO")); /// assert_eq!(lookup.get(SentenceBreak::Numeric), Some("NU")); /// ``` - pub fn get_enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_short_name_mapper() / enum_to_short_name_mapper() -> PropertyEnumToValueNameLinearMapper; /// Return a [`PropertyEnumToValueNameLinearMapper`], capable of looking up long names /// for values of the `Sentence_Break` enumerated property /// @@ -1981,13 +1993,13 @@ impl_value_getter! { /// ``` /// use icu::properties::SentenceBreak; /// - /// let lookup = SentenceBreak::get_enum_to_long_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = SentenceBreak::enum_to_long_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(SentenceBreak::Format), Some("Format")); /// assert_eq!(lookup.get(SentenceBreak::Numeric), Some("Numeric")); /// ``` - pub fn get_enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; + pub fn get_enum_to_long_name_mapper() / enum_to_long_name_mapper() -> PropertyEnumToValueNameLinearMapper; } } /// Property Canonical_Combining_Class. @@ -2085,8 +2097,8 @@ impl_value_getter! { /// ``` /// use icu::properties::CanonicalCombiningClass; /// - /// let lookup = CanonicalCombiningClass::get_name_to_enum_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = CanonicalCombiningClass::name_to_enum_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// // short name for value /// assert_eq!(lookup.get_strict("AL"), Some(CanonicalCombiningClass::AboveLeft)); @@ -2102,7 +2114,7 @@ impl_value_getter! { /// // fake property /// assert_eq!(lookup.get_strict("Linear_Z"), None); /// ``` - pub fn get_name_to_enum_mapper(); + pub fn get_name_to_enum_mapper() / name_to_enum_mapper(); /// Return a [`PropertyEnumToValueNameSparseMapper`], capable of looking up short names /// for values of the `Canonical_Combining_Class` enumerated property /// @@ -2111,14 +2123,14 @@ impl_value_getter! { /// ``` /// use icu::properties::CanonicalCombiningClass; /// - /// let lookup = CanonicalCombiningClass::get_enum_to_short_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = CanonicalCombiningClass::enum_to_short_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(CanonicalCombiningClass::AboveLeft), Some("AL")); /// assert_eq!(lookup.get(CanonicalCombiningClass::AttachedBelowLeft), Some("ATBL")); /// assert_eq!(lookup.get(CanonicalCombiningClass::CCC10), Some("CCC10")); /// ``` - pub fn get_enum_to_short_name_mapper() -> PropertyEnumToValueNameSparseMapper; + pub fn get_enum_to_short_name_mapper() / enum_to_short_name_mapper() -> PropertyEnumToValueNameSparseMapper; /// Return a [`PropertyEnumToValueNameSparseMapper`], capable of looking up long names /// for values of the `Canonical_Combining_Class` enumerated property /// @@ -2127,13 +2139,13 @@ impl_value_getter! { /// ``` /// use icu::properties::CanonicalCombiningClass; /// - /// let lookup = CanonicalCombiningClass::get_enum_to_long_name_mapper(&icu_testdata::unstable()) - /// .expect("The data should be valid"); + /// let lookup = CanonicalCombiningClass::enum_to_long_name_mapper() + /// .expect("locale should be present"); /// let lookup = lookup.as_borrowed(); /// assert_eq!(lookup.get(CanonicalCombiningClass::AboveLeft), Some("Above_Left")); /// assert_eq!(lookup.get(CanonicalCombiningClass::AttachedBelowLeft), Some("Attached_Below_Left")); /// assert_eq!(lookup.get(CanonicalCombiningClass::CCC10), Some("CCC10")); /// ``` - pub fn get_enum_to_long_name_mapper() -> PropertyEnumToValueNameSparseMapper; + pub fn get_enum_to_long_name_mapper() / enum_to_long_name_mapper() -> PropertyEnumToValueNameSparseMapper; } } diff --git a/components/properties/src/sets.rs b/components/properties/src/sets.rs index d23f8797f4f..1b888950882 100644 --- a/components/properties/src/sets.rs +++ b/components/properties/src/sets.rs @@ -324,7 +324,7 @@ macro_rules! make_code_point_set_property { ) => { #[doc = concat!("[`", stringify!($constname), "()`] with a runtime data provider argument.")] /// - /// Note that this will return an owned version of the data. Functionality is available on + /// Note that this will return an owned version of the data. Functionality is available on /// the borrowed version, accessible through `.as_borrowed()`. $vis fn $funcname( provider: &(impl DataProvider<$keyed_data_marker> + ?Sized)