diff --git a/components/collections/src/codepointinvliststringlist/mod.rs b/components/collections/src/codepointinvliststringlist/mod.rs index b1c4467aff1..5d0e196cd24 100644 --- a/components/collections/src/codepointinvliststringlist/mod.rs +++ b/components/collections/src/codepointinvliststringlist/mod.rs @@ -142,17 +142,17 @@ impl<'data> CodePointInversionListAndStringList<'data> { /// /// let cpilsl = CodePointInversionListAndStringList::try_from(cp_list, str_list).unwrap(); /// - /// assert!(cpilsl.contains("bmp_max")); - /// assert!(cpilsl.contains("")); - /// assert!(cpilsl.contains("A")); - /// assert!(cpilsl.contains("ቔ")); // U+1254 ETHIOPIC SYLLABLE QHEE - /// assert!(!cpilsl.contains("bazinga!")); + /// assert!(cpilsl.contains_str("bmp_max")); + /// assert!(cpilsl.contains_str("")); + /// assert!(cpilsl.contains_str("A")); + /// assert!(cpilsl.contains_str("ቔ")); // U+1254 ETHIOPIC SYLLABLE QHEE + /// assert!(!cpilsl.contains_str("bazinga!")); /// ``` - pub fn contains(&self, s: &str) -> bool { + pub fn contains_str(&self, s: &str) -> bool { let mut chars = s.chars(); if let Some(first_char) = chars.next() { if chars.next().is_none() { - return self.contains_char(first_char); + return self.contains(first_char); } } self.str_list.binary_search(s).is_ok() @@ -196,11 +196,11 @@ impl<'data> CodePointInversionListAndStringList<'data> { /// /// let cpilsl = CodePointInversionListAndStringList::try_from(cp_list, str_list).unwrap(); /// - /// assert!(cpilsl.contains_char('A')); - /// assert!(cpilsl.contains_char('ቔ')); // U+1254 ETHIOPIC SYLLABLE QHEE - /// assert!(!cpilsl.contains_char('\u{1_0000}')); - /// assert!(!cpilsl.contains_char('🨫')); // U+1FA2B NEUTRAL CHESS TURNED QUEEN - pub fn contains_char(&self, ch: char) -> bool { + /// assert!(cpilsl.contains('A')); + /// assert!(cpilsl.contains('ቔ')); // U+1254 ETHIOPIC SYLLABLE QHEE + /// assert!(!cpilsl.contains('\u{1_0000}')); + /// assert!(!cpilsl.contains('🨫')); // U+1FA2B NEUTRAL CHESS TURNED QUEEN + pub fn contains(&self, ch: char) -> bool { self.contains32(ch as u32) } @@ -353,14 +353,14 @@ mod tests { assert_eq!(cpilsl_1, cpilsl_2); assert!(cpilsl_1.has_strings()); - assert!(cpilsl_1.contains("abc")); - assert!(cpilsl_1.contains("xyz")); - assert!(!cpilsl_1.contains("def")); + assert!(cpilsl_1.contains_str("abc")); + assert!(cpilsl_1.contains_str("xyz")); + assert!(!cpilsl_1.contains_str("def")); assert_eq!(1, cpilsl_1.cp_inv_list.size()); - assert!(cpilsl_1.contains_char('a')); - assert!(!cpilsl_1.contains_char('0')); - assert!(!cpilsl_1.contains_char('q')); + assert!(cpilsl_1.contains('a')); + assert!(!cpilsl_1.contains('0')); + assert!(!cpilsl_1.contains('q')); assert_eq!(3, cpilsl_1.size()); } diff --git a/components/experimental/src/personnames/specifications/derive_locale.rs b/components/experimental/src/personnames/specifications/derive_locale.rs index ee3cff626f3..f77c879b774 100644 --- a/components/experimental/src/personnames/specifications/derive_locale.rs +++ b/components/experimental/src/personnames/specifications/derive_locale.rs @@ -85,7 +85,7 @@ where .filter(|&name_field| name_field.kind == kind) .find_map(|&name_field| { person_name.get(name_field).chars().find_map(|c| { - let char_script = swe.get_script_val(c as u32); + let char_script = swe.get_script_val(c); match char_script { Script::Common | Script::Unknown | Script::Inherited => None, _ => Some(char_script), diff --git a/components/experimental/src/transliterate/transliterator/mod.rs b/components/experimental/src/transliterate/transliterator/mod.rs index 0c96fb98c65..97e2ff549b0 100644 --- a/components/experimental/src/transliterate/transliterator/mod.rs +++ b/components/experimental/src/transliterate/transliterator/mod.rs @@ -922,10 +922,10 @@ impl<'a> SpecialMatcher<'a> { // eprintln!("checking if set {set:?} matches input {matcher:?}"); if matcher.is_empty() { - if set.contains("") { + if set.contains_str("") { return true; } - if set.contains("\u{FFFF}") { + if set.contains_str("\u{FFFF}") { if matcher.match_end_anchor() { return true; } @@ -961,7 +961,7 @@ impl<'a> SpecialMatcher<'a> { if let Some(input_c) = matcher.next_char() { // eprintln!("checking if set {set:?} contains char {input_c:?}"); - if set.contains_char(input_c) { + if set.contains(input_c) { // eprintln!("contains!"); return matcher.consume(input_c.len_utf8()); } @@ -1025,10 +1025,10 @@ impl<'a> SpecialMatcher<'a> { // eprintln!("checking if set {set:?} reverse matches input {matcher:?}"); if matcher.is_empty() { - if set.contains("") { + if set.contains_str("") { return true; } - if set.contains("\u{FFFF}") { + if set.contains_str("\u{FFFF}") { if matcher.match_end_anchor() { return true; } @@ -1055,7 +1055,7 @@ impl<'a> SpecialMatcher<'a> { if let Some(input_c) = matcher.next_char() { // eprintln!("checking if set {set:?} contains char {input_c:?}"); - if set.contains_char(input_c) { + if set.contains(input_c) { // eprintln!("contains!"); return matcher.consume(input_c.len_utf8()); } diff --git a/components/experimental/src/unicodeset_parse/parse.rs b/components/experimental/src/unicodeset_parse/parse.rs index 709ad4fcacb..ed61a901e2c 100644 --- a/components/experimental/src/unicodeset_parse/parse.rs +++ b/components/experimental/src/unicodeset_parse/parse.rs @@ -1484,7 +1484,7 @@ where /// /// let (set, _) = /// parse(r"[[a-z{hello\ world}]&[^a-y{hello\ world}]]").unwrap(); -/// assert!(set.contains_char('z')); +/// assert!(set.contains('z')); /// assert_eq!(set.size(), 1); /// assert!(!set.has_strings()); /// ``` @@ -1539,7 +1539,7 @@ pub fn parse(source: &str) -> Result<(CodePointInversionListAndStringList<'stati /// let (set, consumed) = parse_with_variables(source, &variable_map).unwrap(); /// assert_eq!(consumed, source.len()); /// assert!(set.code_points().contains_range('d'..='z')); -/// assert!(set.contains("Hello World")); +/// assert!(set.contains_str("Hello World")); /// assert_eq!(set.size(), 1 + ('d'..='z').count()); #[cfg(feature = "compiled_data")] pub fn parse_with_variables( @@ -1788,7 +1788,7 @@ mod tests { for s in strings { expected_size += 1; assert!( - cpinvlistandstrlist.contains(s), + cpinvlistandstrlist.contains_str(s), "missing string \"{}\" from parsed set \"{}\"", s.escape_debug(), source.escape_debug() diff --git a/components/locale/src/exemplar_chars.rs b/components/locale/src/exemplar_chars.rs index 41dde52a538..4e0c380b700 100644 --- a/components/locale/src/exemplar_chars.rs +++ b/components/locale/src/exemplar_chars.rs @@ -23,11 +23,11 @@ //! let exemplars_main = ExemplarCharacters::try_new_main(&locale) //! .expect("locale should be present"); //! -//! assert!(exemplars_main.contains_char('a')); -//! assert!(exemplars_main.contains_char('z')); -//! assert!(exemplars_main.contains("a")); -//! assert!(!exemplars_main.contains("ä")); -//! assert!(!exemplars_main.contains("ng")); +//! assert!(exemplars_main.contains('a')); +//! assert!(exemplars_main.contains('z')); +//! assert!(exemplars_main.contains_str("a")); +//! assert!(!exemplars_main.contains_str("ä")); +//! assert!(!exemplars_main.contains_str("ng")); //! ``` use crate::provider::*; @@ -152,12 +152,12 @@ impl ExemplarCharacters { /// let exemplars_main = ExemplarCharacters::try_new_main(&locale!("en").into()) /// .expect("locale should be present"); /// - /// assert!(exemplars_main.contains_char('a')); - /// assert!(exemplars_main.contains_char('z')); - /// assert!(exemplars_main.contains("a")); - /// assert!(!exemplars_main.contains("ä")); - /// assert!(!exemplars_main.contains("ng")); - /// assert!(!exemplars_main.contains("A")); + /// assert!(exemplars_main.contains('a')); + /// assert!(exemplars_main.contains('z')); + /// assert!(exemplars_main.contains_str("a")); + /// assert!(!exemplars_main.contains_str("ä")); + /// assert!(!exemplars_main.contains_str("ng")); + /// assert!(!exemplars_main.contains_str("A")); /// ``` pub fn try_new_main(); ); @@ -184,12 +184,12 @@ impl ExemplarCharacters { /// ExemplarCharacters::try_new_auxiliary(&locale!("en").into()) /// .expect("locale should be present"); /// - /// assert!(!exemplars_auxiliary.contains_char('a')); - /// assert!(!exemplars_auxiliary.contains_char('z')); - /// assert!(!exemplars_auxiliary.contains("a")); - /// assert!(exemplars_auxiliary.contains("ä")); - /// assert!(!exemplars_auxiliary.contains("ng")); - /// assert!(!exemplars_auxiliary.contains("A")); + /// assert!(!exemplars_auxiliary.contains('a')); + /// assert!(!exemplars_auxiliary.contains('z')); + /// assert!(!exemplars_auxiliary.contains_str("a")); + /// assert!(exemplars_auxiliary.contains_str("ä")); + /// assert!(!exemplars_auxiliary.contains_str("ng")); + /// assert!(!exemplars_auxiliary.contains_str("A")); /// ``` pub fn try_new_auxiliary(); ); @@ -216,13 +216,13 @@ impl ExemplarCharacters { /// ExemplarCharacters::try_new_punctuation(&locale!("en").into()) /// .expect("locale should be present"); /// - /// assert!(!exemplars_punctuation.contains_char('0')); - /// assert!(!exemplars_punctuation.contains_char('9')); - /// assert!(!exemplars_punctuation.contains_char('%')); - /// assert!(exemplars_punctuation.contains_char(',')); - /// assert!(exemplars_punctuation.contains_char('.')); - /// assert!(exemplars_punctuation.contains_char('!')); - /// assert!(exemplars_punctuation.contains_char('?')); + /// assert!(!exemplars_punctuation.contains('0')); + /// assert!(!exemplars_punctuation.contains('9')); + /// assert!(!exemplars_punctuation.contains('%')); + /// assert!(exemplars_punctuation.contains(',')); + /// assert!(exemplars_punctuation.contains('.')); + /// assert!(exemplars_punctuation.contains('!')); + /// assert!(exemplars_punctuation.contains('?')); /// ``` pub fn try_new_punctuation(); ); @@ -249,13 +249,13 @@ impl ExemplarCharacters { /// ExemplarCharacters::try_new_numbers(&locale!("en").into()) /// .expect("locale should be present"); /// - /// assert!(exemplars_numbers.contains_char('0')); - /// assert!(exemplars_numbers.contains_char('9')); - /// assert!(exemplars_numbers.contains_char('%')); - /// assert!(exemplars_numbers.contains_char(',')); - /// assert!(exemplars_numbers.contains_char('.')); - /// assert!(!exemplars_numbers.contains_char('!')); - /// assert!(!exemplars_numbers.contains_char('?')); + /// assert!(exemplars_numbers.contains('0')); + /// assert!(exemplars_numbers.contains('9')); + /// assert!(exemplars_numbers.contains('%')); + /// assert!(exemplars_numbers.contains(',')); + /// assert!(exemplars_numbers.contains('.')); + /// assert!(!exemplars_numbers.contains('!')); + /// assert!(!exemplars_numbers.contains('?')); /// ``` pub fn try_new_numbers(); ); @@ -282,12 +282,12 @@ impl ExemplarCharacters { /// ExemplarCharacters::try_new_index(&locale!("en").into()) /// .expect("locale should be present"); /// - /// assert!(!exemplars_index.contains_char('a')); - /// assert!(!exemplars_index.contains_char('z')); - /// assert!(!exemplars_index.contains("a")); - /// assert!(!exemplars_index.contains("ä")); - /// assert!(!exemplars_index.contains("ng")); - /// assert!(exemplars_index.contains("A")); + /// assert!(!exemplars_index.contains('a')); + /// assert!(!exemplars_index.contains('z')); + /// assert!(!exemplars_index.contains_str("a")); + /// assert!(!exemplars_index.contains_str("ä")); + /// assert!(!exemplars_index.contains_str("ng")); + /// assert!(exemplars_index.contains_str("A")); /// ``` pub fn try_new_index(); ); diff --git a/components/properties/README.md b/components/properties/README.md index 86785c49ccb..7eed6df4865 100644 --- a/components/properties/README.md +++ b/components/properties/README.md @@ -32,8 +32,8 @@ let line_sep_data = CodePointMapData::::new() .get_set_for_value(GeneralCategory::LineSeparator); let line_sep = line_sep_data.as_borrowed(); -assert!(line_sep.contains32(0x2028)); -assert!(!line_sep.contains32(0x2029)); +assert!(line_sep.contains('\u{2028}')); +assert!(!line_sep.contains('\u{2029}')); ``` ### Property data as `CodePointMapData`s diff --git a/components/properties/src/code_point_map.rs b/components/properties/src/code_point_map.rs index 64b55c839d4..a9baa2da498 100644 --- a/components/properties/src/code_point_map.rs +++ b/components/properties/src/code_point_map.rs @@ -162,19 +162,7 @@ impl<'a, T: TrieValue> CodePointMapDataBorrowed<'a, T> { self.map.get32(ch as u32) } - /// Get the value this map has associated with code point `ch` - /// - /// # Example - /// - /// ``` - /// use icu::properties::CodePointMapData; - /// use icu::properties::props::GeneralCategory; - /// - /// let gc = CodePointMapData::::new(); - /// - /// assert_eq!(gc.get32(0x6728), GeneralCategory::OtherLetter); // U+6728 (木) - /// assert_eq!(gc.get32(0x1F383), GeneralCategory::OtherSymbol); // U+1F383 JACK-O-LANTERN - /// ``` + /// See [`Self::get`]. pub fn get32(self, ch: u32) -> T { self.map.get32(ch) } diff --git a/components/properties/src/code_point_set.rs b/components/properties/src/code_point_set.rs index 33d95a0520f..13920589632 100644 --- a/components/properties/src/code_point_set.rs +++ b/components/properties/src/code_point_set.rs @@ -142,17 +142,7 @@ impl<'a> CodePointSetDataBorrowed<'a> { self.set.contains(ch) } - /// Check if the set contains a character as a UTF32 code unit - /// - /// ```rust - /// use icu::properties::CodePointSetData; - /// use icu::properties::props::Alphabetic; - /// - /// let alphabetic = CodePointSetData::new::(); - /// - /// assert!(!alphabetic.contains32(0x0A69)); // U+0A69 GURMUKHI DIGIT THREE - /// assert!(alphabetic.contains32(0x00C4)); // U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS - /// ``` + /// See [`Self::contains`]. #[inline] pub fn contains32(self, ch: u32) -> bool { self.set.contains32(ch) diff --git a/components/properties/src/lib.rs b/components/properties/src/lib.rs index 8254b4565e4..e21a97f9a26 100644 --- a/components/properties/src/lib.rs +++ b/components/properties/src/lib.rs @@ -32,8 +32,8 @@ //! .get_set_for_value(GeneralCategory::LineSeparator); //! let line_sep = line_sep_data.as_borrowed(); //! -//! assert!(line_sep.contains32(0x2028)); -//! assert!(!line_sep.contains32(0x2029)); +//! assert!(line_sep.contains('\u{2028}')); +//! assert!(!line_sep.contains('\u{2029}')); //! ``` //! //! ## Property data as `CodePointMapData`s diff --git a/components/properties/src/props.rs b/components/properties/src/props.rs index 2565bdaef71..6b5a218d817 100644 --- a/components/properties/src/props.rs +++ b/components/properties/src/props.rs @@ -457,9 +457,9 @@ impl GeneralCategoryGroup { /// assert!(!GeneralCategoryGroup::CasedLetter.contains(gc.get('ଞ'))); /// /// // U+0301 COMBINING ACUTE ACCENT - /// assert_eq!(gc.get32(0x0301), GeneralCategory::NonspacingMark); - /// assert!(GeneralCategoryGroup::Mark.contains(gc.get32(0x0301))); - /// assert!(!GeneralCategoryGroup::Letter.contains(gc.get32(0x0301))); + /// assert_eq!(gc.get('\u{0301}'), GeneralCategory::NonspacingMark); + /// assert!(GeneralCategoryGroup::Mark.contains(gc.get('\u{0301}'))); + /// assert!(!GeneralCategoryGroup::Letter.contains(gc.get('\u{0301}'))); /// /// assert_eq!(gc.get('0'), GeneralCategory::DecimalNumber); /// assert!(GeneralCategoryGroup::Number.contains(gc.get('0'))); @@ -479,9 +479,9 @@ impl GeneralCategoryGroup { /// assert!(!GeneralCategoryGroup::Symbol.contains(gc.get(' '))); /// /// // U+E007F CANCEL TAG - /// assert_eq!(gc.get32(0xE007F), GeneralCategory::Format); - /// assert!(GeneralCategoryGroup::Other.contains(gc.get32(0xE007F))); - /// assert!(!GeneralCategoryGroup::Separator.contains(gc.get32(0xE007F))); + /// assert_eq!(gc.get('\u{E007F}'), GeneralCategory::Format); + /// assert!(GeneralCategoryGroup::Other.contains(gc.get('\u{E007F}'))); + /// assert!(!GeneralCategoryGroup::Separator.contains(gc.get('\u{E007F}'))); /// ``` pub const fn contains(&self, val: GeneralCategory) -> bool { 0 != (1 << (val as u32)) & self.0 @@ -1312,7 +1312,7 @@ make_enumerated_property! { /// use icu::properties::{maps, CanonicalCombiningClass}; /// /// assert_eq!(maps::canonical_combining_class().get('a'), CanonicalCombiningClass::NotReordered); // U+0061: LATIN SMALL LETTER A - /// assert_eq!(maps::canonical_combining_class().get32(0x0301), CanonicalCombiningClass::Above); // U+0301: COMBINING ACUTE ACCENT + /// assert_eq!(maps::canonical_combining_class().get('\u{0301}'), CanonicalCombiningClass::Above); // U+0301: COMBINING ACUTE ACCENT /// ``` } @@ -1389,7 +1389,7 @@ make_enumerated_property! { /// use icu::properties::{maps, IndicSyllabicCategory}; /// /// assert_eq!(maps::indic_syllabic_category().get('a'), IndicSyllabicCategory::Other); - /// assert_eq!(maps::indic_syllabic_category().get32(0x0900), IndicSyllabicCategory::Bindu); // U+0900: DEVANAGARI SIGN INVERTED CANDRABINDU + /// assert_eq!(maps::indic_syllabic_category().get('\u{0900}'), IndicSyllabicCategory::Bindu); // U+0900: DEVANAGARI SIGN INVERTED CANDRABINDU /// ``` } @@ -1548,7 +1548,7 @@ make_binary_property! { /// /// let bidi_control = CodePointSetData::new::(); /// - /// assert!(bidi_control.contains32(0x200F)); // RIGHT-TO-LEFT MARK + /// assert!(bidi_control.contains('\u{200F}')); // RIGHT-TO-LEFT MARK /// assert!(!bidi_control.contains('ش')); // U+0634 ARABIC LETTER SHEEN /// ``` @@ -1843,7 +1843,7 @@ make_binary_property! { /// /// let default_ignorable_code_point = CodePointSetData::new::(); /// - /// assert!(default_ignorable_code_point.contains32(0x180B)); // MONGOLIAN FREE VARIATION SELECTOR ONE + /// assert!(default_ignorable_code_point.contains('\u{180B}')); // MONGOLIAN FREE VARIATION SELECTOR ONE /// assert!(!default_ignorable_code_point.contains('E')); /// ``` @@ -1914,7 +1914,7 @@ make_binary_property! { /// let emoji_component = CodePointSetData::new::(); /// /// assert!(emoji_component.contains('🇹')); // U+1F1F9 REGIONAL INDICATOR SYMBOL LETTER T - /// assert!(emoji_component.contains32(0x20E3)); // COMBINING ENCLOSING KEYCAP + /// assert!(emoji_component.contains('\u{20E3}')); // COMBINING ENCLOSING KEYCAP /// assert!(emoji_component.contains('7')); /// assert!(!emoji_component.contains('T')); /// ``` @@ -1938,8 +1938,8 @@ make_binary_property! { /// /// let emoji_modifier = CodePointSetData::new::(); /// - /// assert!(emoji_modifier.contains32(0x1F3FD)); // EMOJI MODIFIER FITZPATRICK TYPE-4 - /// assert!(!emoji_modifier.contains32(0x200C)); // ZERO WIDTH NON-JOINER + /// assert!(emoji_modifier.contains('\u{1F3FD}')); // EMOJI MODIFIER FITZPATRICK TYPE-4 + /// assert!(!emoji_modifier.contains('\u{200C}')); // ZERO WIDTH NON-JOINER /// ``` } @@ -2178,7 +2178,7 @@ make_binary_property! { /// assert!(id_continue.contains('_')); /// assert!(id_continue.contains('ߝ')); // U+07DD NKO LETTER FA /// assert!(!id_continue.contains('ⓧ')); // U+24E7 CIRCLED LATIN SMALL LETTER X - /// assert!(id_continue.contains32(0xFC5E)); // ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM + /// assert!(id_continue.contains('\u{FC5E}')); // ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM /// ``` } @@ -2231,7 +2231,7 @@ make_binary_property! { /// assert!(!id_start.contains('_')); /// assert!(id_start.contains('ߝ')); // U+07DD NKO LETTER FA /// assert!(!id_start.contains('ⓧ')); // U+24E7 CIRCLED LATIN SMALL LETTER X - /// assert!(id_start.contains32(0xFC5E)); // ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM + /// assert!(id_start.contains('\u{FC5E}')); // ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM /// ``` } @@ -2253,8 +2253,8 @@ make_binary_property! { /// /// let ids_binary_operator = CodePointSetData::new::(); /// - /// assert!(ids_binary_operator.contains32(0x2FF5)); // IDEOGRAPHIC DESCRIPTION CHARACTER SURROUND FROM ABOVE - /// assert!(!ids_binary_operator.contains32(0x3006)); // IDEOGRAPHIC CLOSING MARK + /// assert!(ids_binary_operator.contains('\u{2FF5}')); // IDEOGRAPHIC DESCRIPTION CHARACTER SURROUND FROM ABOVE + /// assert!(!ids_binary_operator.contains('\u{3006}')); // IDEOGRAPHIC CLOSING MARK /// ``` } @@ -2276,11 +2276,11 @@ make_binary_property! { /// /// let ids_trinary_operator = CodePointSetData::new::(); /// - /// assert!(ids_trinary_operator.contains32(0x2FF2)); // IDEOGRAPHIC DESCRIPTION CHARACTER LEFT TO MIDDLE AND RIGHT - /// assert!(ids_trinary_operator.contains32(0x2FF3)); // IDEOGRAPHIC DESCRIPTION CHARACTER ABOVE TO MIDDLE AND BELOW - /// assert!(!ids_trinary_operator.contains32(0x2FF4)); - /// assert!(!ids_trinary_operator.contains32(0x2FF5)); // IDEOGRAPHIC DESCRIPTION CHARACTER SURROUND FROM ABOVE - /// assert!(!ids_trinary_operator.contains32(0x3006)); // IDEOGRAPHIC CLOSING MARK + /// assert!(ids_trinary_operator.contains('\u{2FF2}')); // IDEOGRAPHIC DESCRIPTION CHARACTER LEFT TO MIDDLE AND RIGHT + /// assert!(ids_trinary_operator.contains('\u{2FF3}')); // IDEOGRAPHIC DESCRIPTION CHARACTER ABOVE TO MIDDLE AND BELOW + /// assert!(!ids_trinary_operator.contains('\u{2FF4}')); + /// assert!(!ids_trinary_operator.contains('\u{2FF5}')); // IDEOGRAPHIC DESCRIPTION CHARACTER SURROUND FROM ABOVE + /// assert!(!ids_trinary_operator.contains('\u{3006}')); // IDEOGRAPHIC CLOSING MARK /// ``` } @@ -2303,9 +2303,9 @@ make_binary_property! { /// /// let join_control = CodePointSetData::new::(); /// - /// assert!(join_control.contains32(0x200C)); // ZERO WIDTH NON-JOINER - /// assert!(join_control.contains32(0x200D)); // ZERO WIDTH JOINER - /// assert!(!join_control.contains32(0x200E)); + /// assert!(join_control.contains('\u{200C}')); // ZERO WIDTH NON-JOINER + /// assert!(join_control.contains('\u{200D}')); // ZERO WIDTH JOINER + /// assert!(!join_control.contains('\u{200E}')); /// ``` } @@ -2400,9 +2400,9 @@ make_binary_property! { /// /// let noncharacter_code_point = CodePointSetData::new::(); /// - /// assert!(noncharacter_code_point.contains32(0xFDD0)); - /// assert!(noncharacter_code_point.contains32(0xFFFF)); - /// assert!(!noncharacter_code_point.contains32(0x10000)); + /// assert!(noncharacter_code_point.contains('\u{FDD0}')); + /// assert!(noncharacter_code_point.contains('\u{FFFF}')); + /// assert!(!noncharacter_code_point.contains('\u{10000}')); /// ``` } @@ -2497,9 +2497,9 @@ make_binary_property! { /// let pattern_white_space = CodePointSetData::new::(); /// /// assert!(pattern_white_space.contains(' ')); - /// assert!(pattern_white_space.contains32(0x2029)); // PARAGRAPH SEPARATOR - /// assert!(pattern_white_space.contains32(0x000A)); // NEW LINE - /// assert!(!pattern_white_space.contains32(0x00A0)); // NO-BREAK SPACE + /// assert!(pattern_white_space.contains('\u{2029}')); // PARAGRAPH SEPARATOR + /// assert!(pattern_white_space.contains('\u{000A}')); // NEW LINE + /// assert!(!pattern_white_space.contains('\u{00A0}')); // NO-BREAK SPACE /// ``` } @@ -2763,11 +2763,11 @@ make_binary_property! { /// /// let variation_selector = CodePointSetData::new::(); /// - /// assert!(variation_selector.contains32(0x180D)); // MONGOLIAN FREE VARIATION SELECTOR THREE - /// assert!(!variation_selector.contains32(0x303E)); // IDEOGRAPHIC VARIATION INDICATOR - /// assert!(variation_selector.contains32(0xFE0F)); // VARIATION SELECTOR-16 - /// assert!(!variation_selector.contains32(0xFE10)); // PRESENTATION FORM FOR VERTICAL COMMA - /// assert!(variation_selector.contains32(0xE01EF)); // VARIATION SELECTOR-256 + /// assert!(variation_selector.contains('\u{180D}')); // MONGOLIAN FREE VARIATION SELECTOR THREE + /// assert!(!variation_selector.contains('\u{303E}')); // IDEOGRAPHIC VARIATION INDICATOR + /// assert!(variation_selector.contains('\u{FE0F}')); // VARIATION SELECTOR-16 + /// assert!(!variation_selector.contains('\u{FE10}')); // PRESENTATION FORM FOR VERTICAL COMMA + /// assert!(variation_selector.contains('\u{E01EF}')); // VARIATION SELECTOR-256 /// ``` } @@ -2791,9 +2791,9 @@ make_binary_property! { /// let white_space = CodePointSetData::new::(); /// /// assert!(white_space.contains(' ')); - /// assert!(white_space.contains32(0x000A)); // NEW LINE - /// assert!(white_space.contains32(0x00A0)); // NO-BREAK SPACE - /// assert!(!white_space.contains32(0x200B)); // ZERO WIDTH SPACE + /// assert!(white_space.contains('\u{000A}')); // NEW LINE + /// assert!(white_space.contains('\u{00A0}')); // NO-BREAK SPACE + /// assert!(!white_space.contains('\u{200B}')); // ZERO WIDTH SPACE /// ``` } @@ -2833,7 +2833,7 @@ make_binary_property! { /// assert!(xid_continue.contains('_')); /// assert!(xid_continue.contains('ߝ')); // U+07DD NKO LETTER FA /// assert!(!xid_continue.contains('ⓧ')); // U+24E7 CIRCLED LATIN SMALL LETTER X - /// assert!(!xid_continue.contains32(0xFC5E)); // ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM + /// assert!(!xid_continue.contains('\u{FC5E}')); // ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM /// ``` } @@ -2862,7 +2862,7 @@ make_binary_property! { /// assert!(!xid_start.contains('_')); /// assert!(xid_start.contains('ߝ')); // U+07DD NKO LETTER FA /// assert!(!xid_start.contains('ⓧ')); // U+24E7 CIRCLED LATIN SMALL LETTER X - /// assert!(!xid_start.contains32(0xFC5E)); // ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM + /// assert!(!xid_start.contains('\u{FC5E}')); // ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM /// ``` } @@ -2910,12 +2910,12 @@ make_string_set_property! { /// /// let basic_emoji = UnicodeSetData::new::(); /// - /// assert!(!basic_emoji.contains32(0x0020)); - /// assert!(!basic_emoji.contains_char('\n')); - /// assert!(basic_emoji.contains_char('🦃')); // U+1F983 TURKEY - /// assert!(basic_emoji.contains("\u{1F983}")); - /// assert!(basic_emoji.contains("\u{1F6E4}\u{FE0F}")); // railway track - /// assert!(!basic_emoji.contains("\u{0033}\u{FE0F}\u{20E3}")); // Emoji_Keycap_Sequence, keycap 3 + /// assert!(!basic_emoji.contains('\u{0020}')); + /// assert!(!basic_emoji.contains('\n')); + /// assert!(basic_emoji.contains('🦃')); // U+1F983 TURKEY + /// assert!(basic_emoji.contains_str("\u{1F983}")); + /// assert!(basic_emoji.contains_str("\u{1F6E4}\u{FE0F}")); // railway track + /// assert!(!basic_emoji.contains_str("\u{0033}\u{FE0F}\u{20E3}")); // Emoji_Keycap_Sequence, keycap 3 /// ``` } diff --git a/components/properties/src/provider.rs b/components/properties/src/provider.rs index e92829a140d..c748d1a650e 100644 --- a/components/properties/src/provider.rs +++ b/components/properties/src/provider.rs @@ -629,9 +629,9 @@ pub enum PropertyUnicodeSetV1<'data> { impl<'data> PropertyUnicodeSetV1<'data> { #[inline] - pub(crate) fn contains(&self, s: &str) -> bool { + pub(crate) fn contains_str(&self, s: &str) -> bool { match *self { - Self::CPInversionListStrList(ref l) => l.contains(s), + Self::CPInversionListStrList(ref l) => l.contains_str(s), } } @@ -643,9 +643,9 @@ impl<'data> PropertyUnicodeSetV1<'data> { } #[inline] - pub(crate) fn contains_char(&self, ch: char) -> bool { + pub(crate) fn contains(&self, ch: char) -> bool { match *self { - Self::CPInversionListStrList(ref l) => l.contains_char(ch), + Self::CPInversionListStrList(ref l) => l.contains(ch), } } diff --git a/components/properties/src/script.rs b/components/properties/src/script.rs index 31aee28b688..52886d74101 100644 --- a/components/properties/src/script.rs +++ b/components/properties/src/script.rs @@ -190,7 +190,7 @@ impl<'a> ScriptExtensionsSet<'a> { /// let swe = ScriptWithExtensions::new(); /// /// assert!(swe - /// .get_script_extensions_val(0x11303) // GRANTHA SIGN VISARGA + /// .get_script_extensions_val('\u{11303}') // GRANTHA SIGN VISARGA /// .contains(&Script::Grantha)); /// ``` pub fn contains(&self, x: &Script) -> bool { @@ -207,7 +207,7 @@ impl<'a> ScriptExtensionsSet<'a> { /// let swe = ScriptWithExtensions::new(); /// /// assert_eq!( - /// swe.get_script_extensions_val('௫' as u32) // U+0BEB TAMIL DIGIT FIVE + /// swe.get_script_extensions_val('௫') // U+0BEB TAMIL DIGIT FIVE /// .iter() /// .collect::>(), /// [Script::Tamil, Script::Grantha] @@ -245,49 +245,49 @@ impl<'a> ScriptExtensionsSet<'a> { /// let swe = ScriptWithExtensions::new(); /// /// // get the `Script` property value -/// assert_eq!(swe.get_script_val(0x0640), Script::Common); // U+0640 ARABIC TATWEEL -/// assert_eq!(swe.get_script_val(0x0650), Script::Inherited); // U+0650 ARABIC KASRA -/// assert_eq!(swe.get_script_val(0x0660), Script::Arabic); // // U+0660 ARABIC-INDIC DIGIT ZERO -/// assert_eq!(swe.get_script_val(0xFDF2), Script::Arabic); // U+FDF2 ARABIC LIGATURE ALLAH ISOLATED FORM +/// assert_eq!(swe.get_script_val('ـ'), Script::Common); // U+0640 ARABIC TATWEEL +/// assert_eq!(swe.get_script_val('\u{0650}'), Script::Inherited); // U+0650 ARABIC KASRA +/// assert_eq!(swe.get_script_val('٠'), Script::Arabic); // // U+0660 ARABIC-INDIC DIGIT ZERO +/// assert_eq!(swe.get_script_val('ﷲ'), Script::Arabic); // U+FDF2 ARABIC LIGATURE ALLAH ISOLATED FORM /// /// // get the `Script_Extensions` property value /// assert_eq!( -/// swe.get_script_extensions_val(0x0640) // U+0640 ARABIC TATWEEL +/// swe.get_script_extensions_val('ـ') // U+0640 ARABIC TATWEEL /// .iter().collect::>(), /// [Script::Arabic, Script::Syriac, Script::Mandaic, Script::Manichaean, /// Script::PsalterPahlavi, Script::Adlam, Script::HanifiRohingya, Script::Sogdian, /// Script::OldUyghur] /// ); /// assert_eq!( -/// swe.get_script_extensions_val('🥳' as u32) // U+1F973 FACE WITH PARTY HORN AND PARTY HAT +/// swe.get_script_extensions_val('🥳') // U+1F973 FACE WITH PARTY HORN AND PARTY HAT /// .iter().collect::>(), /// [Script::Common] /// ); /// assert_eq!( -/// swe.get_script_extensions_val(0x200D) // ZERO WIDTH JOINER +/// swe.get_script_extensions_val('\u{200D}') // ZERO WIDTH JOINER /// .iter().collect::>(), /// [Script::Inherited] /// ); /// assert_eq!( -/// swe.get_script_extensions_val('௫' as u32) // U+0BEB TAMIL DIGIT FIVE +/// swe.get_script_extensions_val('௫') // U+0BEB TAMIL DIGIT FIVE /// .iter().collect::>(), /// [Script::Tamil, Script::Grantha] /// ); /// /// // check containment of a `Script` value in the `Script_Extensions` value /// // U+0650 ARABIC KASRA -/// assert!(!swe.has_script(0x0650, Script::Inherited)); // main Script value -/// assert!(swe.has_script(0x0650, Script::Arabic)); -/// assert!(swe.has_script(0x0650, Script::Syriac)); -/// assert!(!swe.has_script(0x0650, Script::Thaana)); +/// assert!(!swe.has_script('\u{0650}', Script::Inherited)); // main Script value +/// assert!(swe.has_script('\u{0650}', Script::Arabic)); +/// assert!(swe.has_script('\u{0650}', Script::Syriac)); +/// assert!(!swe.has_script('\u{0650}', Script::Thaana)); /// /// // get a `CodePointInversionList` for when `Script` value is contained in `Script_Extensions` value /// let syriac = swe.get_script_extensions_set(Script::Syriac); -/// assert!(syriac.contains32(0x0650)); // ARABIC KASRA -/// assert!(!syriac.contains32(0x0660)); // ARABIC-INDIC DIGIT ZERO -/// assert!(!syriac.contains32(0xFDF2)); // ARABIC LIGATURE ALLAH ISOLATED FORM -/// assert!(syriac.contains32(0x0700)); // SYRIAC END OF PARAGRAPH -/// assert!(syriac.contains32(0x074A)); // SYRIAC BARREKH +/// assert!(syriac.contains('\u{0650}')); // ARABIC KASRA +/// assert!(!syriac.contains('٠')); // ARABIC-INDIC DIGIT ZERO +/// assert!(!syriac.contains('ﷲ')); // ARABIC LIGATURE ALLAH ISOLATED FORM +/// assert!(syriac.contains('܀')); // SYRIAC END OF PARAGRAPH +/// assert!(syriac.contains('\u{074A}')); // SYRIAC BARREKH /// ``` #[derive(Debug)] pub struct ScriptWithExtensions { @@ -366,30 +366,35 @@ impl<'a> ScriptWithExtensionsBorrowed<'a> { /// let swe = ScriptWithExtensions::new(); /// /// // U+0640 ARABIC TATWEEL - /// assert_eq!(swe.get_script_val(0x0640), Script::Common); // main Script value - /// assert_ne!(swe.get_script_val(0x0640), Script::Arabic); - /// assert_ne!(swe.get_script_val(0x0640), Script::Syriac); - /// assert_ne!(swe.get_script_val(0x0640), Script::Thaana); + /// assert_eq!(swe.get_script_val('ـ'), Script::Common); // main Script value + /// assert_ne!(swe.get_script_val('ـ'), Script::Arabic); + /// assert_ne!(swe.get_script_val('ـ'), Script::Syriac); + /// assert_ne!(swe.get_script_val('ـ'), Script::Thaana); /// /// // U+0650 ARABIC KASRA - /// assert_eq!(swe.get_script_val(0x0650), Script::Inherited); // main Script value - /// assert_ne!(swe.get_script_val(0x0650), Script::Arabic); - /// assert_ne!(swe.get_script_val(0x0650), Script::Syriac); - /// assert_ne!(swe.get_script_val(0x0650), Script::Thaana); + /// assert_eq!(swe.get_script_val('\u{0650}'), Script::Inherited); // main Script value + /// assert_ne!(swe.get_script_val('\u{0650}'), Script::Arabic); + /// assert_ne!(swe.get_script_val('\u{0650}'), Script::Syriac); + /// assert_ne!(swe.get_script_val('\u{0650}'), Script::Thaana); /// /// // U+0660 ARABIC-INDIC DIGIT ZERO - /// assert_ne!(swe.get_script_val(0x0660), Script::Common); - /// assert_eq!(swe.get_script_val(0x0660), Script::Arabic); // main Script value - /// assert_ne!(swe.get_script_val(0x0660), Script::Syriac); - /// assert_ne!(swe.get_script_val(0x0660), Script::Thaana); + /// assert_ne!(swe.get_script_val('٠'), Script::Common); + /// assert_eq!(swe.get_script_val('٠'), Script::Arabic); // main Script value + /// assert_ne!(swe.get_script_val('٠'), Script::Syriac); + /// assert_ne!(swe.get_script_val('٠'), Script::Thaana); /// /// // U+FDF2 ARABIC LIGATURE ALLAH ISOLATED FORM - /// assert_ne!(swe.get_script_val(0xFDF2), Script::Common); - /// assert_eq!(swe.get_script_val(0xFDF2), Script::Arabic); // main Script value - /// assert_ne!(swe.get_script_val(0xFDF2), Script::Syriac); - /// assert_ne!(swe.get_script_val(0xFDF2), Script::Thaana); + /// assert_ne!(swe.get_script_val('ﷲ'), Script::Common); + /// assert_eq!(swe.get_script_val('ﷲ'), Script::Arabic); // main Script value + /// assert_ne!(swe.get_script_val('ﷲ'), Script::Syriac); + /// assert_ne!(swe.get_script_val('ﷲ'), Script::Thaana); /// ``` - pub fn get_script_val(self, code_point: u32) -> Script { + pub fn get_script_val(self, ch: char) -> Script { + self.get_script_val32(ch as u32) + } + + /// See [`Self::get_script_val`]. + pub fn get_script_val32(self, code_point: u32) -> Script { let sc_with_ext = self.data.trie.get32(code_point); if sc_with_ext.is_other() { @@ -460,31 +465,36 @@ impl<'a> ScriptWithExtensionsBorrowed<'a> { /// let swe = ScriptWithExtensions::new(); /// /// assert_eq!( - /// swe.get_script_extensions_val('𐓐' as u32) // U+104D0 OSAGE CAPITAL LETTER KHA + /// swe.get_script_extensions_val('𐓐') // U+104D0 OSAGE CAPITAL LETTER KHA /// .iter() /// .collect::>(), /// [Script::Osage] /// ); /// assert_eq!( - /// swe.get_script_extensions_val('🥳' as u32) // U+1F973 FACE WITH PARTY HORN AND PARTY HAT + /// swe.get_script_extensions_val('🥳') // U+1F973 FACE WITH PARTY HORN AND PARTY HAT /// .iter() /// .collect::>(), /// [Script::Common] /// ); /// assert_eq!( - /// swe.get_script_extensions_val(0x200D) // ZERO WIDTH JOINER + /// swe.get_script_extensions_val('\u{200D}') // ZERO WIDTH JOINER /// .iter() /// .collect::>(), /// [Script::Inherited] /// ); /// assert_eq!( - /// swe.get_script_extensions_val('௫' as u32) // U+0BEB TAMIL DIGIT FIVE + /// swe.get_script_extensions_val('௫') // U+0BEB TAMIL DIGIT FIVE /// .iter() /// .collect::>(), /// [Script::Tamil, Script::Grantha] /// ); /// ``` - pub fn get_script_extensions_val(self, code_point: u32) -> ScriptExtensionsSet<'a> { + pub fn get_script_extensions_val(self, ch: char) -> ScriptExtensionsSet<'a> { + self.get_script_extensions_val32(ch as u32) + } + + /// See [`Self::get_script_extensions_val`]. + pub fn get_script_extensions_val32(self, code_point: u32) -> ScriptExtensionsSet<'a> { let sc_with_ext_ule = self.data.trie.get32_ule(code_point); ScriptExtensionsSet { @@ -512,24 +522,29 @@ impl<'a> ScriptWithExtensionsBorrowed<'a> { /// let swe = ScriptWithExtensions::new(); /// /// // U+0650 ARABIC KASRA - /// assert!(!swe.has_script(0x0650, Script::Inherited)); // main Script value - /// assert!(swe.has_script(0x0650, Script::Arabic)); - /// assert!(swe.has_script(0x0650, Script::Syriac)); - /// assert!(!swe.has_script(0x0650, Script::Thaana)); + /// assert!(!swe.has_script('\u{0650}', Script::Inherited)); // main Script value + /// assert!(swe.has_script('\u{0650}', Script::Arabic)); + /// assert!(swe.has_script('\u{0650}', Script::Syriac)); + /// assert!(!swe.has_script('\u{0650}', Script::Thaana)); /// /// // U+0660 ARABIC-INDIC DIGIT ZERO - /// assert!(!swe.has_script(0x0660, Script::Common)); // main Script value - /// assert!(swe.has_script(0x0660, Script::Arabic)); - /// assert!(!swe.has_script(0x0660, Script::Syriac)); - /// assert!(swe.has_script(0x0660, Script::Thaana)); + /// assert!(!swe.has_script('٠', Script::Common)); // main Script value + /// assert!(swe.has_script('٠', Script::Arabic)); + /// assert!(!swe.has_script('٠', Script::Syriac)); + /// assert!(swe.has_script('٠', Script::Thaana)); /// /// // U+FDF2 ARABIC LIGATURE ALLAH ISOLATED FORM - /// assert!(!swe.has_script(0xFDF2, Script::Common)); - /// assert!(swe.has_script(0xFDF2, Script::Arabic)); // main Script value - /// assert!(!swe.has_script(0xFDF2, Script::Syriac)); - /// assert!(swe.has_script(0xFDF2, Script::Thaana)); + /// assert!(!swe.has_script('ﷲ', Script::Common)); + /// assert!(swe.has_script('ﷲ', Script::Arabic)); // main Script value + /// assert!(!swe.has_script('ﷲ', Script::Syriac)); + /// assert!(swe.has_script('ﷲ', Script::Thaana)); /// ``` - pub fn has_script(self, code_point: u32, script: Script) -> bool { + pub fn has_script(self, ch: char, script: Script) -> bool { + self.has_script32(ch as u32, script) + } + + /// See [`Self::has_script`]. + pub fn has_script32(self, code_point: u32, script: Script) -> bool { let sc_with_ext_ule = if let Some(scwe_ule) = self.data.trie.get32_ule(code_point) { scwe_ule } else { @@ -610,20 +625,20 @@ impl<'a> ScriptWithExtensionsBorrowed<'a> { /// /// let syriac = swe.get_script_extensions_set(Script::Syriac); /// - /// assert!(!syriac.contains32(0x061E)); // ARABIC TRIPLE DOT PUNCTUATION MARK - /// assert!(syriac.contains32(0x061F)); // ARABIC QUESTION MARK - /// assert!(!syriac.contains32(0x0620)); // ARABIC LETTER KASHMIRI YEH + /// assert!(!syriac.contains('؞')); // ARABIC TRIPLE DOT PUNCTUATION MARK + /// assert!(syriac.contains('؟')); // ARABIC QUESTION MARK + /// assert!(!syriac.contains('ؠ')); // ARABIC LETTER KASHMIRI YEH /// - /// assert!(syriac.contains32(0x0700)); // SYRIAC END OF PARAGRAPH - /// assert!(syriac.contains32(0x074A)); // SYRIAC BARREKH - /// assert!(!syriac.contains32(0x074B)); // unassigned - /// assert!(syriac.contains32(0x074F)); // SYRIAC LETTER SOGDIAN FE - /// assert!(!syriac.contains32(0x0750)); // ARABIC LETTER BEH WITH THREE DOTS HORIZONTALLY BELOW + /// assert!(syriac.contains('܀')); // SYRIAC END OF PARAGRAPH + /// assert!(syriac.contains('\u{074A}')); // SYRIAC BARREKH + /// assert!(!syriac.contains('\u{074B}')); // unassigned + /// assert!(syriac.contains('ݏ')); // SYRIAC LETTER SOGDIAN FE + /// assert!(!syriac.contains('ݐ')); // ARABIC LETTER BEH WITH THREE DOTS HORIZONTALLY BELOW /// - /// assert!(syriac.contains32(0x1DF8)); // COMBINING DOT ABOVE LEFT - /// assert!(!syriac.contains32(0x1DF9)); // COMBINING WIDE INVERTED BRIDGE BELOW - /// assert!(syriac.contains32(0x1DFA)); // COMBINING DOT BELOW LEFT - /// assert!(!syriac.contains32(0x1DFB)); // COMBINING DELETION MARK + /// assert!(syriac.contains('\u{1DF8}')); // COMBINING DOT ABOVE LEFT + /// assert!(!syriac.contains('\u{1DF9}')); // COMBINING WIDE INVERTED BRIDGE BELOW + /// assert!(syriac.contains('\u{1DFA}')); // COMBINING DOT BELOW LEFT + /// assert!(!syriac.contains('\u{1DFB}')); // COMBINING DELETION MARK /// ``` pub fn get_script_extensions_set(self, script: Script) -> CodePointInversionList<'a> { CodePointInversionList::from_iter(self.get_script_extensions_ranges(script)) diff --git a/components/properties/src/unicode_set.rs b/components/properties/src/unicode_set.rs index 7d1d754688c..294cc61424d 100644 --- a/components/properties/src/unicode_set.rs +++ b/components/properties/src/unicode_set.rs @@ -114,20 +114,20 @@ impl<'a> UnicodeSetDataBorrowed<'a> { /// /// This matches ICU behavior for ICU's `UnicodeSet`. #[inline] - pub fn contains(self, s: &str) -> bool { - self.set.contains(s) + pub fn contains_str(self, s: &str) -> bool { + self.set.contains_str(s) } - /// Check if the set contains a character as a UTF32 code unit + /// Check if the set contains the code point. #[inline] - pub fn contains32(&self, cp: u32) -> bool { - self.set.contains32(cp) + pub fn contains(&self, ch: char) -> bool { + self.set.contains(ch) } - /// Check if the set contains the code point corresponding to the Rust character. + /// See [`Self::contains`]. #[inline] - pub fn contains_char(&self, ch: char) -> bool { - self.set.contains_char(ch) + pub fn contains32(&self, cp: u32) -> bool { + self.set.contains32(cp) } } diff --git a/ffi/capi/bindings/c/CodePointRangeIteratorResult.d.h b/ffi/capi/bindings/c/CodePointRangeIteratorResult.d.h index db874e39a0b..0a3ad0f45f0 100644 --- a/ffi/capi/bindings/c/CodePointRangeIteratorResult.d.h +++ b/ffi/capi/bindings/c/CodePointRangeIteratorResult.d.h @@ -12,8 +12,8 @@ typedef struct CodePointRangeIteratorResult { - uint32_t start; - uint32_t end; + char32_t start; + char32_t end; bool done; } CodePointRangeIteratorResult; diff --git a/ffi/capi/bindings/c/ExemplarCharacters.h b/ffi/capi/bindings/c/ExemplarCharacters.h index 7687551f221..1a69df87b1f 100644 --- a/ffi/capi/bindings/c/ExemplarCharacters.h +++ b/ffi/capi/bindings/c/ExemplarCharacters.h @@ -18,9 +18,9 @@ -bool icu4x_ExemplarCharacters_contains_mv1(const ExemplarCharacters* self, DiplomatStringView s); +bool icu4x_ExemplarCharacters_contains_str_mv1(const ExemplarCharacters* self, DiplomatStringView s); -bool icu4x_ExemplarCharacters_contains_char_mv1(const ExemplarCharacters* self, char32_t cp); +bool icu4x_ExemplarCharacters_contains_mv1(const ExemplarCharacters* self, char32_t cp); typedef struct icu4x_ExemplarCharacters_try_new_main_mv1_result {union {ExemplarCharacters* ok; DataError err;}; bool is_ok;} icu4x_ExemplarCharacters_try_new_main_mv1_result; icu4x_ExemplarCharacters_try_new_main_mv1_result icu4x_ExemplarCharacters_try_new_main_mv1(const DataProvider* provider, const Locale* locale); diff --git a/ffi/capi/bindings/c/ScriptWithExtensions.h b/ffi/capi/bindings/c/ScriptWithExtensions.h index 22ff0154023..cef1d1a3020 100644 --- a/ffi/capi/bindings/c/ScriptWithExtensions.h +++ b/ffi/capi/bindings/c/ScriptWithExtensions.h @@ -22,9 +22,9 @@ typedef struct icu4x_ScriptWithExtensions_create_mv1_result {union {ScriptWithExtensions* ok; DataError err;}; bool is_ok;} icu4x_ScriptWithExtensions_create_mv1_result; icu4x_ScriptWithExtensions_create_mv1_result icu4x_ScriptWithExtensions_create_mv1(const DataProvider* provider); -uint16_t icu4x_ScriptWithExtensions_get_script_val_mv1(const ScriptWithExtensions* self, uint32_t code_point); +uint16_t icu4x_ScriptWithExtensions_get_script_val_mv1(const ScriptWithExtensions* self, char32_t ch); -bool icu4x_ScriptWithExtensions_has_script_mv1(const ScriptWithExtensions* self, uint32_t code_point, uint16_t script); +bool icu4x_ScriptWithExtensions_has_script_mv1(const ScriptWithExtensions* self, char32_t ch, uint16_t script); ScriptWithExtensionsBorrowed* icu4x_ScriptWithExtensions_as_borrowed_mv1(const ScriptWithExtensions* self); diff --git a/ffi/capi/bindings/c/ScriptWithExtensionsBorrowed.h b/ffi/capi/bindings/c/ScriptWithExtensionsBorrowed.h index f87c57f03b4..02f20845408 100644 --- a/ffi/capi/bindings/c/ScriptWithExtensionsBorrowed.h +++ b/ffi/capi/bindings/c/ScriptWithExtensionsBorrowed.h @@ -17,11 +17,11 @@ -uint16_t icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(const ScriptWithExtensionsBorrowed* self, uint32_t code_point); +uint16_t icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(const ScriptWithExtensionsBorrowed* self, char32_t ch); -ScriptExtensionsSet* icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(const ScriptWithExtensionsBorrowed* self, uint32_t code_point); +ScriptExtensionsSet* icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(const ScriptWithExtensionsBorrowed* self, char32_t ch); -bool icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(const ScriptWithExtensionsBorrowed* self, uint32_t code_point, uint16_t script); +bool icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(const ScriptWithExtensionsBorrowed* self, char32_t ch, uint16_t script); CodePointSetData* icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_set_mv1(const ScriptWithExtensionsBorrowed* self, uint16_t script); diff --git a/ffi/capi/bindings/c/UnicodeSetData.h b/ffi/capi/bindings/c/UnicodeSetData.h index 757f059d291..3cc1a1a7317 100644 --- a/ffi/capi/bindings/c/UnicodeSetData.h +++ b/ffi/capi/bindings/c/UnicodeSetData.h @@ -17,9 +17,9 @@ -bool icu4x_UnicodeSetData_contains_mv1(const UnicodeSetData* self, DiplomatStringView s); +bool icu4x_UnicodeSetData_contains_str_mv1(const UnicodeSetData* self, DiplomatStringView s); -bool icu4x_UnicodeSetData_contains_char_mv1(const UnicodeSetData* self, char32_t cp); +bool icu4x_UnicodeSetData_contains_mv1(const UnicodeSetData* self, char32_t cp); typedef struct icu4x_UnicodeSetData_load_basic_emoji_mv1_result {union {UnicodeSetData* ok; DataError err;}; bool is_ok;} icu4x_UnicodeSetData_load_basic_emoji_mv1_result; icu4x_UnicodeSetData_load_basic_emoji_mv1_result icu4x_UnicodeSetData_load_basic_emoji_mv1(const DataProvider* provider); diff --git a/ffi/capi/bindings/cpp/icu4x/CodePointRangeIteratorResult.d.hpp b/ffi/capi/bindings/cpp/icu4x/CodePointRangeIteratorResult.d.hpp index cac500e6be1..53b335887bc 100644 --- a/ffi/capi/bindings/cpp/icu4x/CodePointRangeIteratorResult.d.hpp +++ b/ffi/capi/bindings/cpp/icu4x/CodePointRangeIteratorResult.d.hpp @@ -13,8 +13,8 @@ namespace icu4x { namespace capi { struct CodePointRangeIteratorResult { - uint32_t start; - uint32_t end; + char32_t start; + char32_t end; bool done; }; @@ -25,8 +25,8 @@ namespace capi { namespace icu4x { struct CodePointRangeIteratorResult { - uint32_t start; - uint32_t end; + char32_t start; + char32_t end; bool done; inline icu4x::capi::CodePointRangeIteratorResult AsFFI() const; diff --git a/ffi/capi/bindings/cpp/icu4x/ExemplarCharacters.d.hpp b/ffi/capi/bindings/cpp/icu4x/ExemplarCharacters.d.hpp index 615128352fd..2abead995ae 100644 --- a/ffi/capi/bindings/cpp/icu4x/ExemplarCharacters.d.hpp +++ b/ffi/capi/bindings/cpp/icu4x/ExemplarCharacters.d.hpp @@ -32,7 +32,7 @@ class ExemplarCharacters { inline bool contains(std::string_view s) const; - inline bool contains_char(char32_t cp) const; + inline bool contains(char32_t cp) const; inline static diplomat::result, icu4x::DataError> try_new_main(const icu4x::DataProvider& provider, const icu4x::Locale& locale); diff --git a/ffi/capi/bindings/cpp/icu4x/ExemplarCharacters.hpp b/ffi/capi/bindings/cpp/icu4x/ExemplarCharacters.hpp index a9217740599..dc506e3d716 100644 --- a/ffi/capi/bindings/cpp/icu4x/ExemplarCharacters.hpp +++ b/ffi/capi/bindings/cpp/icu4x/ExemplarCharacters.hpp @@ -19,9 +19,9 @@ namespace icu4x { namespace capi { extern "C" { - bool icu4x_ExemplarCharacters_contains_mv1(const icu4x::capi::ExemplarCharacters* self, diplomat::capi::DiplomatStringView s); + bool icu4x_ExemplarCharacters_contains_str_mv1(const icu4x::capi::ExemplarCharacters* self, diplomat::capi::DiplomatStringView s); - bool icu4x_ExemplarCharacters_contains_char_mv1(const icu4x::capi::ExemplarCharacters* self, char32_t cp); + bool icu4x_ExemplarCharacters_contains_mv1(const icu4x::capi::ExemplarCharacters* self, char32_t cp); typedef struct icu4x_ExemplarCharacters_try_new_main_mv1_result {union {icu4x::capi::ExemplarCharacters* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_ExemplarCharacters_try_new_main_mv1_result; icu4x_ExemplarCharacters_try_new_main_mv1_result icu4x_ExemplarCharacters_try_new_main_mv1(const icu4x::capi::DataProvider* provider, const icu4x::capi::Locale* locale); @@ -46,13 +46,13 @@ namespace capi { } // namespace inline bool icu4x::ExemplarCharacters::contains(std::string_view s) const { - auto result = icu4x::capi::icu4x_ExemplarCharacters_contains_mv1(this->AsFFI(), + auto result = icu4x::capi::icu4x_ExemplarCharacters_contains_str_mv1(this->AsFFI(), {s.data(), s.size()}); return result; } -inline bool icu4x::ExemplarCharacters::contains_char(char32_t cp) const { - auto result = icu4x::capi::icu4x_ExemplarCharacters_contains_char_mv1(this->AsFFI(), +inline bool icu4x::ExemplarCharacters::contains(char32_t cp) const { + auto result = icu4x::capi::icu4x_ExemplarCharacters_contains_mv1(this->AsFFI(), cp); return result; } diff --git a/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensions.d.hpp b/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensions.d.hpp index 1d47a2674cc..7061d25435c 100644 --- a/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensions.d.hpp +++ b/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensions.d.hpp @@ -34,9 +34,9 @@ class ScriptWithExtensions { inline static diplomat::result, icu4x::DataError> create(const icu4x::DataProvider& provider); - inline uint16_t get_script_val(uint32_t code_point) const; + inline uint16_t get_script_val(char32_t ch) const; - inline bool has_script(uint32_t code_point, uint16_t script) const; + inline bool has_script(char32_t ch, uint16_t script) const; inline std::unique_ptr as_borrowed() const; diff --git a/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensions.hpp b/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensions.hpp index 58809683839..acea04b396d 100644 --- a/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensions.hpp +++ b/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensions.hpp @@ -23,9 +23,9 @@ namespace capi { typedef struct icu4x_ScriptWithExtensions_create_mv1_result {union {icu4x::capi::ScriptWithExtensions* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_ScriptWithExtensions_create_mv1_result; icu4x_ScriptWithExtensions_create_mv1_result icu4x_ScriptWithExtensions_create_mv1(const icu4x::capi::DataProvider* provider); - uint16_t icu4x_ScriptWithExtensions_get_script_val_mv1(const icu4x::capi::ScriptWithExtensions* self, uint32_t code_point); + uint16_t icu4x_ScriptWithExtensions_get_script_val_mv1(const icu4x::capi::ScriptWithExtensions* self, char32_t ch); - bool icu4x_ScriptWithExtensions_has_script_mv1(const icu4x::capi::ScriptWithExtensions* self, uint32_t code_point, uint16_t script); + bool icu4x_ScriptWithExtensions_has_script_mv1(const icu4x::capi::ScriptWithExtensions* self, char32_t ch, uint16_t script); icu4x::capi::ScriptWithExtensionsBorrowed* icu4x_ScriptWithExtensions_as_borrowed_mv1(const icu4x::capi::ScriptWithExtensions* self); @@ -43,15 +43,15 @@ inline diplomat::result, icu4x::Dat return result.is_ok ? diplomat::result, icu4x::DataError>(diplomat::Ok>(std::unique_ptr(icu4x::ScriptWithExtensions::FromFFI(result.ok)))) : diplomat::result, icu4x::DataError>(diplomat::Err(icu4x::DataError::FromFFI(result.err))); } -inline uint16_t icu4x::ScriptWithExtensions::get_script_val(uint32_t code_point) const { +inline uint16_t icu4x::ScriptWithExtensions::get_script_val(char32_t ch) const { auto result = icu4x::capi::icu4x_ScriptWithExtensions_get_script_val_mv1(this->AsFFI(), - code_point); + ch); return result; } -inline bool icu4x::ScriptWithExtensions::has_script(uint32_t code_point, uint16_t script) const { +inline bool icu4x::ScriptWithExtensions::has_script(char32_t ch, uint16_t script) const { auto result = icu4x::capi::icu4x_ScriptWithExtensions_has_script_mv1(this->AsFFI(), - code_point, + ch, script); return result; } diff --git a/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensionsBorrowed.d.hpp b/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensionsBorrowed.d.hpp index 9ebe66fb85a..7e1a90b560c 100644 --- a/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensionsBorrowed.d.hpp +++ b/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensionsBorrowed.d.hpp @@ -27,11 +27,11 @@ namespace icu4x { class ScriptWithExtensionsBorrowed { public: - inline uint16_t get_script_val(uint32_t code_point) const; + inline uint16_t get_script_val(char32_t ch) const; - inline std::unique_ptr get_script_extensions_val(uint32_t code_point) const; + inline std::unique_ptr get_script_extensions_val(char32_t ch) const; - inline bool has_script(uint32_t code_point, uint16_t script) const; + inline bool has_script(char32_t ch, uint16_t script) const; inline std::unique_ptr get_script_extensions_set(uint16_t script) const; diff --git a/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensionsBorrowed.hpp b/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensionsBorrowed.hpp index fedcbd49f43..5dac9f800b4 100644 --- a/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensionsBorrowed.hpp +++ b/ffi/capi/bindings/cpp/icu4x/ScriptWithExtensionsBorrowed.hpp @@ -18,11 +18,11 @@ namespace icu4x { namespace capi { extern "C" { - uint16_t icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(const icu4x::capi::ScriptWithExtensionsBorrowed* self, uint32_t code_point); + uint16_t icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(const icu4x::capi::ScriptWithExtensionsBorrowed* self, char32_t ch); - icu4x::capi::ScriptExtensionsSet* icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(const icu4x::capi::ScriptWithExtensionsBorrowed* self, uint32_t code_point); + icu4x::capi::ScriptExtensionsSet* icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(const icu4x::capi::ScriptWithExtensionsBorrowed* self, char32_t ch); - bool icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(const icu4x::capi::ScriptWithExtensionsBorrowed* self, uint32_t code_point, uint16_t script); + bool icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(const icu4x::capi::ScriptWithExtensionsBorrowed* self, char32_t ch, uint16_t script); icu4x::capi::CodePointSetData* icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_set_mv1(const icu4x::capi::ScriptWithExtensionsBorrowed* self, uint16_t script); @@ -33,21 +33,21 @@ namespace capi { } // namespace capi } // namespace -inline uint16_t icu4x::ScriptWithExtensionsBorrowed::get_script_val(uint32_t code_point) const { +inline uint16_t icu4x::ScriptWithExtensionsBorrowed::get_script_val(char32_t ch) const { auto result = icu4x::capi::icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(this->AsFFI(), - code_point); + ch); return result; } -inline std::unique_ptr icu4x::ScriptWithExtensionsBorrowed::get_script_extensions_val(uint32_t code_point) const { +inline std::unique_ptr icu4x::ScriptWithExtensionsBorrowed::get_script_extensions_val(char32_t ch) const { auto result = icu4x::capi::icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(this->AsFFI(), - code_point); + ch); return std::unique_ptr(icu4x::ScriptExtensionsSet::FromFFI(result)); } -inline bool icu4x::ScriptWithExtensionsBorrowed::has_script(uint32_t code_point, uint16_t script) const { +inline bool icu4x::ScriptWithExtensionsBorrowed::has_script(char32_t ch, uint16_t script) const { auto result = icu4x::capi::icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(this->AsFFI(), - code_point, + ch, script); return result; } diff --git a/ffi/capi/bindings/cpp/icu4x/UnicodeSetData.d.hpp b/ffi/capi/bindings/cpp/icu4x/UnicodeSetData.d.hpp index f54a7ec0d3e..53da30ff418 100644 --- a/ffi/capi/bindings/cpp/icu4x/UnicodeSetData.d.hpp +++ b/ffi/capi/bindings/cpp/icu4x/UnicodeSetData.d.hpp @@ -30,7 +30,7 @@ class UnicodeSetData { inline bool contains(std::string_view s) const; - inline bool contains_char(char32_t cp) const; + inline bool contains(char32_t cp) const; inline static diplomat::result, icu4x::DataError> load_basic_emoji(const icu4x::DataProvider& provider); diff --git a/ffi/capi/bindings/cpp/icu4x/UnicodeSetData.hpp b/ffi/capi/bindings/cpp/icu4x/UnicodeSetData.hpp index ef2c5457b1d..f42c3039869 100644 --- a/ffi/capi/bindings/cpp/icu4x/UnicodeSetData.hpp +++ b/ffi/capi/bindings/cpp/icu4x/UnicodeSetData.hpp @@ -18,9 +18,9 @@ namespace icu4x { namespace capi { extern "C" { - bool icu4x_UnicodeSetData_contains_mv1(const icu4x::capi::UnicodeSetData* self, diplomat::capi::DiplomatStringView s); + bool icu4x_UnicodeSetData_contains_str_mv1(const icu4x::capi::UnicodeSetData* self, diplomat::capi::DiplomatStringView s); - bool icu4x_UnicodeSetData_contains_char_mv1(const icu4x::capi::UnicodeSetData* self, char32_t cp); + bool icu4x_UnicodeSetData_contains_mv1(const icu4x::capi::UnicodeSetData* self, char32_t cp); typedef struct icu4x_UnicodeSetData_load_basic_emoji_mv1_result {union {icu4x::capi::UnicodeSetData* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_UnicodeSetData_load_basic_emoji_mv1_result; icu4x_UnicodeSetData_load_basic_emoji_mv1_result icu4x_UnicodeSetData_load_basic_emoji_mv1(const icu4x::capi::DataProvider* provider); @@ -33,13 +33,13 @@ namespace capi { } // namespace inline bool icu4x::UnicodeSetData::contains(std::string_view s) const { - auto result = icu4x::capi::icu4x_UnicodeSetData_contains_mv1(this->AsFFI(), + auto result = icu4x::capi::icu4x_UnicodeSetData_contains_str_mv1(this->AsFFI(), {s.data(), s.size()}); return result; } -inline bool icu4x::UnicodeSetData::contains_char(char32_t cp) const { - auto result = icu4x::capi::icu4x_UnicodeSetData_contains_char_mv1(this->AsFFI(), +inline bool icu4x::UnicodeSetData::contains(char32_t cp) const { + auto result = icu4x::capi::icu4x_UnicodeSetData_contains_mv1(this->AsFFI(), cp); return result; } diff --git a/ffi/capi/bindings/dart/CodePointRangeIteratorResult.g.dart b/ffi/capi/bindings/dart/CodePointRangeIteratorResult.g.dart index 650ac4b0ca5..093ef1d7c30 100644 --- a/ffi/capi/bindings/dart/CodePointRangeIteratorResult.g.dart +++ b/ffi/capi/bindings/dart/CodePointRangeIteratorResult.g.dart @@ -4,23 +4,23 @@ part of 'lib.g.dart'; final class _CodePointRangeIteratorResultFfi extends ffi.Struct { @ffi.Uint32() - external int start; + external Rune start; @ffi.Uint32() - external int end; + external Rune end; @ffi.Bool() external bool done; } /// Result of a single iteration of [`CodePointRangeIterator`]. -/// Logically can be considered to be an `Option>`, +/// Logically can be considered to be an `Option>`, /// /// `start` and `end` represent an inclusive range of code points [start, end], /// and `done` will be true if the iterator has already finished. The last contentful /// iteration will NOT produce a range done=true, in other words `start` and `end` are useful /// values if and only if `done=false`. final class CodePointRangeIteratorResult { - final int start; - final int end; + final Rune start; + final Rune end; final bool done; // This struct contains borrowed fields, so this takes in a list of diff --git a/ffi/capi/bindings/dart/ExemplarCharacters.g.dart b/ffi/capi/bindings/dart/ExemplarCharacters.g.dart index d0f7067dbc8..3dc19669f37 100644 --- a/ffi/capi/bindings/dart/ExemplarCharacters.g.dart +++ b/ffi/capi/bindings/dart/ExemplarCharacters.g.dart @@ -30,18 +30,18 @@ final class ExemplarCharacters implements ffi.Finalizable { /// Checks whether the string is in the set. /// - /// See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/collections/codepointinvliststringlist/struct.CodePointInversionListAndStringList.html#method.contains) for more information. - bool contains(String s) { + /// See the [Rust documentation for `contains_str`](https://docs.rs/icu/latest/icu/collections/codepointinvliststringlist/struct.CodePointInversionListAndStringList.html#method.contains_str) for more information. + bool containsStr(String s) { final temp = _FinalizedArena(); - final result = _icu4x_ExemplarCharacters_contains_mv1(_ffi, s._utf8AllocIn(temp.arena)); + final result = _icu4x_ExemplarCharacters_contains_str_mv1(_ffi, s._utf8AllocIn(temp.arena)); return result; } /// Checks whether the code point is in the set. /// - /// See the [Rust documentation for `contains_char`](https://docs.rs/icu/latest/icu/collections/codepointinvliststringlist/struct.CodePointInversionListAndStringList.html#method.contains_char) for more information. - bool containsChar(Rune cp) { - final result = _icu4x_ExemplarCharacters_contains_char_mv1(_ffi, cp); + /// See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/collections/codepointinvliststringlist/struct.CodePointInversionListAndStringList.html#method.contains) for more information. + bool contains(Rune cp) { + final result = _icu4x_ExemplarCharacters_contains_mv1(_ffi, cp); return result; } @@ -107,14 +107,14 @@ final class ExemplarCharacters implements ffi.Finalizable { external void _icu4x_ExemplarCharacters_destroy_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_ExemplarCharacters_contains_mv1') +@ffi.Native, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_ExemplarCharacters_contains_str_mv1') // ignore: non_constant_identifier_names -external bool _icu4x_ExemplarCharacters_contains_mv1(ffi.Pointer self, _SliceUtf8 s); +external bool _icu4x_ExemplarCharacters_contains_str_mv1(ffi.Pointer self, _SliceUtf8 s); @meta.RecordUse() -@ffi.Native, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_ExemplarCharacters_contains_char_mv1') +@ffi.Native, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_ExemplarCharacters_contains_mv1') // ignore: non_constant_identifier_names -external bool _icu4x_ExemplarCharacters_contains_char_mv1(ffi.Pointer self, Rune cp); +external bool _icu4x_ExemplarCharacters_contains_mv1(ffi.Pointer self, Rune cp); @meta.RecordUse() @ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer, ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_ExemplarCharacters_try_new_main_mv1') diff --git a/ffi/capi/bindings/dart/ScriptWithExtensions.g.dart b/ffi/capi/bindings/dart/ScriptWithExtensions.g.dart index 4d906d70d68..ad25df7800b 100644 --- a/ffi/capi/bindings/dart/ScriptWithExtensions.g.dart +++ b/ffi/capi/bindings/dart/ScriptWithExtensions.g.dart @@ -38,16 +38,16 @@ final class ScriptWithExtensions implements ffi.Finalizable { /// Get the Script property value for a code point /// /// See the [Rust documentation for `get_script_val`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_val) for more information. - int getScriptVal(int codePoint) { - final result = _icu4x_ScriptWithExtensions_get_script_val_mv1(_ffi, codePoint); + int getScriptVal(Rune ch) { + final result = _icu4x_ScriptWithExtensions_get_script_val_mv1(_ffi, ch); return result; } /// Check if the Script_Extensions property of the given code point covers the given script /// /// See the [Rust documentation for `has_script`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.has_script) for more information. - bool hasScript(int codePoint, int script) { - final result = _icu4x_ScriptWithExtensions_has_script_mv1(_ffi, codePoint, script); + bool hasScript(Rune ch, int script) { + final result = _icu4x_ScriptWithExtensions_has_script_mv1(_ffi, ch, script); return result; } @@ -85,12 +85,12 @@ external _ResultOpaqueInt32 _icu4x_ScriptWithExtensions_create_mv1(ffi.Pointer, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_ScriptWithExtensions_get_script_val_mv1') // ignore: non_constant_identifier_names -external int _icu4x_ScriptWithExtensions_get_script_val_mv1(ffi.Pointer self, int codePoint); +external int _icu4x_ScriptWithExtensions_get_script_val_mv1(ffi.Pointer self, Rune ch); @meta.RecordUse() @ffi.Native, ffi.Uint32, ffi.Uint16)>(isLeaf: true, symbol: 'icu4x_ScriptWithExtensions_has_script_mv1') // ignore: non_constant_identifier_names -external bool _icu4x_ScriptWithExtensions_has_script_mv1(ffi.Pointer self, int codePoint, int script); +external bool _icu4x_ScriptWithExtensions_has_script_mv1(ffi.Pointer self, Rune ch, int script); @meta.RecordUse() @ffi.Native Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_ScriptWithExtensions_as_borrowed_mv1') diff --git a/ffi/capi/bindings/dart/ScriptWithExtensionsBorrowed.g.dart b/ffi/capi/bindings/dart/ScriptWithExtensionsBorrowed.g.dart index 6b83e11ac9d..8471fbb65b7 100644 --- a/ffi/capi/bindings/dart/ScriptWithExtensionsBorrowed.g.dart +++ b/ffi/capi/bindings/dart/ScriptWithExtensionsBorrowed.g.dart @@ -26,29 +26,30 @@ final class ScriptWithExtensionsBorrowed implements ffi.Finalizable { static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_icu4x_ScriptWithExtensionsBorrowed_destroy_mv1)); + /// Get the Script property value for a code point /// Get the Script property value for a code point /// /// See the [Rust documentation for `get_script_val`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_val) for more information. - int getScriptVal(int codePoint) { - final result = _icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(_ffi, codePoint); + int getScriptVal(Rune ch) { + final result = _icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(_ffi, ch); return result; } /// Get the Script property value for a code point /// /// See the [Rust documentation for `get_script_extensions_val`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_extensions_val) for more information. - ScriptExtensionsSet getScriptExtensionsVal(int codePoint) { + ScriptExtensionsSet getScriptExtensionsVal(Rune ch) { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(_ffi, codePoint); + final result = _icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(_ffi, ch); return ScriptExtensionsSet._fromFfi(result, [], aEdges); } /// Check if the Script_Extensions property of the given code point covers the given script /// /// See the [Rust documentation for `has_script`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.has_script) for more information. - bool hasScript(int codePoint, int script) { - final result = _icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(_ffi, codePoint, script); + bool hasScript(Rune ch, int script) { + final result = _icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(_ffi, ch, script); return result; } @@ -70,17 +71,17 @@ external void _icu4x_ScriptWithExtensionsBorrowed_destroy_mv1(ffi.Pointer, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1') // ignore: non_constant_identifier_names -external int _icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(ffi.Pointer self, int codePoint); +external int _icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(ffi.Pointer self, Rune ch); @meta.RecordUse() @ffi.Native Function(ffi.Pointer, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1') // ignore: non_constant_identifier_names -external ffi.Pointer _icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(ffi.Pointer self, int codePoint); +external ffi.Pointer _icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(ffi.Pointer self, Rune ch); @meta.RecordUse() @ffi.Native, ffi.Uint32, ffi.Uint16)>(isLeaf: true, symbol: 'icu4x_ScriptWithExtensionsBorrowed_has_script_mv1') // ignore: non_constant_identifier_names -external bool _icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(ffi.Pointer self, int codePoint, int script); +external bool _icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(ffi.Pointer self, Rune ch, int script); @meta.RecordUse() @ffi.Native Function(ffi.Pointer, ffi.Uint16)>(isLeaf: true, symbol: 'icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_set_mv1') diff --git a/ffi/capi/bindings/dart/UnicodeSetData.g.dart b/ffi/capi/bindings/dart/UnicodeSetData.g.dart index 32788b0a792..e396eb4f3c8 100644 --- a/ffi/capi/bindings/dart/UnicodeSetData.g.dart +++ b/ffi/capi/bindings/dart/UnicodeSetData.g.dart @@ -32,18 +32,18 @@ final class UnicodeSetData implements ffi.Finalizable { /// Checks whether the string is in the set. /// - /// See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/struct.UnicodeSetDataBorrowed.html#method.contains) for more information. - bool contains(String s) { + /// See the [Rust documentation for `contains_str`](https://docs.rs/icu/latest/icu/properties/struct.UnicodeSetDataBorrowed.html#method.contains_str) for more information. + bool containsStr(String s) { final temp = _FinalizedArena(); - final result = _icu4x_UnicodeSetData_contains_mv1(_ffi, s._utf8AllocIn(temp.arena)); + final result = _icu4x_UnicodeSetData_contains_str_mv1(_ffi, s._utf8AllocIn(temp.arena)); return result; } /// Checks whether the code point is in the set. /// - /// See the [Rust documentation for `contains_char`](https://docs.rs/icu/latest/icu/properties/struct.UnicodeSetDataBorrowed.html#method.contains_char) for more information. - bool containsChar(Rune cp) { - final result = _icu4x_UnicodeSetData_contains_char_mv1(_ffi, cp); + /// See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/struct.UnicodeSetDataBorrowed.html#method.contains) for more information. + bool contains(Rune cp) { + final result = _icu4x_UnicodeSetData_contains_mv1(_ffi, cp); return result; } @@ -65,14 +65,14 @@ final class UnicodeSetData implements ffi.Finalizable { external void _icu4x_UnicodeSetData_destroy_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_UnicodeSetData_contains_mv1') +@ffi.Native, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_UnicodeSetData_contains_str_mv1') // ignore: non_constant_identifier_names -external bool _icu4x_UnicodeSetData_contains_mv1(ffi.Pointer self, _SliceUtf8 s); +external bool _icu4x_UnicodeSetData_contains_str_mv1(ffi.Pointer self, _SliceUtf8 s); @meta.RecordUse() -@ffi.Native, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_UnicodeSetData_contains_char_mv1') +@ffi.Native, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_UnicodeSetData_contains_mv1') // ignore: non_constant_identifier_names -external bool _icu4x_UnicodeSetData_contains_char_mv1(ffi.Pointer self, Rune cp); +external bool _icu4x_UnicodeSetData_contains_mv1(ffi.Pointer self, Rune cp); @meta.RecordUse() @ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_UnicodeSetData_load_basic_emoji_mv1') diff --git a/ffi/capi/bindings/js/CodePointRangeIteratorResult.d.ts b/ffi/capi/bindings/js/CodePointRangeIteratorResult.d.ts index df4c9807533..1ca68356f5d 100644 --- a/ffi/capi/bindings/js/CodePointRangeIteratorResult.d.ts +++ b/ffi/capi/bindings/js/CodePointRangeIteratorResult.d.ts @@ -3,7 +3,7 @@ import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; /** Result of a single iteration of [`CodePointRangeIterator`]. -*Logically can be considered to be an `Option>`, +*Logically can be considered to be an `Option>`, * *`start` and `end` represent an inclusive range of code points [start, end], *and `done` will be true if the iterator has already finished. The last contentful @@ -12,10 +12,10 @@ import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; */ export class CodePointRangeIteratorResult { - get start() : number; + get start() : codepoint; - get end() : number; + get end() : codepoint; get done() : boolean; diff --git a/ffi/capi/bindings/js/CodePointRangeIteratorResult.mjs b/ffi/capi/bindings/js/CodePointRangeIteratorResult.mjs index 1cfe11be78d..95555e188f9 100644 --- a/ffi/capi/bindings/js/CodePointRangeIteratorResult.mjs +++ b/ffi/capi/bindings/js/CodePointRangeIteratorResult.mjs @@ -4,7 +4,7 @@ import * as diplomatRuntime from "./diplomat-runtime.mjs"; /** Result of a single iteration of [`CodePointRangeIterator`]. -*Logically can be considered to be an `Option>`, +*Logically can be considered to be an `Option>`, * *`start` and `end` represent an inclusive range of code points [start, end], *and `done` will be true if the iterator has already finished. The last contentful diff --git a/ffi/capi/bindings/js/ExemplarCharacters.d.ts b/ffi/capi/bindings/js/ExemplarCharacters.d.ts index a87d37faebb..dd5381be615 100644 --- a/ffi/capi/bindings/js/ExemplarCharacters.d.ts +++ b/ffi/capi/bindings/js/ExemplarCharacters.d.ts @@ -18,9 +18,9 @@ export class ExemplarCharacters { get ffiValue(): pointer; - contains(s: string): boolean; + containsStr(s: string): boolean; - containsChar(cp: codepoint): boolean; + contains(cp: codepoint): boolean; static tryNewMain(provider: DataProvider, locale: Locale): ExemplarCharacters; diff --git a/ffi/capi/bindings/js/ExemplarCharacters.mjs b/ffi/capi/bindings/js/ExemplarCharacters.mjs index fafba1bdc77..9a51d3ca89c 100644 --- a/ffi/capi/bindings/js/ExemplarCharacters.mjs +++ b/ffi/capi/bindings/js/ExemplarCharacters.mjs @@ -45,12 +45,12 @@ export class ExemplarCharacters { return this.#ptr; } - contains(s) { + containsStr(s) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); const sSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, s)); - const result = wasm.icu4x_ExemplarCharacters_contains_mv1(this.ffiValue, ...sSlice.splat()); + const result = wasm.icu4x_ExemplarCharacters_contains_str_mv1(this.ffiValue, ...sSlice.splat()); try { return result; @@ -61,8 +61,8 @@ export class ExemplarCharacters { } } - containsChar(cp) { - const result = wasm.icu4x_ExemplarCharacters_contains_char_mv1(this.ffiValue, cp); + contains(cp) { + const result = wasm.icu4x_ExemplarCharacters_contains_mv1(this.ffiValue, cp); try { return result; diff --git a/ffi/capi/bindings/js/ScriptWithExtensions.d.ts b/ffi/capi/bindings/js/ScriptWithExtensions.d.ts index 13c7033c58c..491d8d1bfd6 100644 --- a/ffi/capi/bindings/js/ScriptWithExtensions.d.ts +++ b/ffi/capi/bindings/js/ScriptWithExtensions.d.ts @@ -17,9 +17,9 @@ export class ScriptWithExtensions { static create(provider: DataProvider): ScriptWithExtensions; - getScriptVal(codePoint: number): number; + getScriptVal(ch: codepoint): number; - hasScript(codePoint: number, script: number): boolean; + hasScript(ch: codepoint, script: number): boolean; get asBorrowed(): ScriptWithExtensionsBorrowed; diff --git a/ffi/capi/bindings/js/ScriptWithExtensions.mjs b/ffi/capi/bindings/js/ScriptWithExtensions.mjs index 140564f863d..1b73c3a4be6 100644 --- a/ffi/capi/bindings/js/ScriptWithExtensions.mjs +++ b/ffi/capi/bindings/js/ScriptWithExtensions.mjs @@ -60,8 +60,8 @@ export class ScriptWithExtensions { } } - getScriptVal(codePoint) { - const result = wasm.icu4x_ScriptWithExtensions_get_script_val_mv1(this.ffiValue, codePoint); + getScriptVal(ch) { + const result = wasm.icu4x_ScriptWithExtensions_get_script_val_mv1(this.ffiValue, ch); try { return result; @@ -70,8 +70,8 @@ export class ScriptWithExtensions { finally {} } - hasScript(codePoint, script) { - const result = wasm.icu4x_ScriptWithExtensions_has_script_mv1(this.ffiValue, codePoint, script); + hasScript(ch, script) { + const result = wasm.icu4x_ScriptWithExtensions_has_script_mv1(this.ffiValue, ch, script); try { return result; diff --git a/ffi/capi/bindings/js/ScriptWithExtensionsBorrowed.d.ts b/ffi/capi/bindings/js/ScriptWithExtensionsBorrowed.d.ts index 0fee67be776..be7c4b169bd 100644 --- a/ffi/capi/bindings/js/ScriptWithExtensionsBorrowed.d.ts +++ b/ffi/capi/bindings/js/ScriptWithExtensionsBorrowed.d.ts @@ -13,11 +13,11 @@ export class ScriptWithExtensionsBorrowed { get ffiValue(): pointer; - getScriptVal(codePoint: number): number; + getScriptVal(ch: codepoint): number; - getScriptExtensionsVal(codePoint: number): ScriptExtensionsSet; + getScriptExtensionsVal(ch: codepoint): ScriptExtensionsSet; - hasScript(codePoint: number, script: number): boolean; + hasScript(ch: codepoint, script: number): boolean; getScriptExtensionsSet(script: number): CodePointSetData; } \ No newline at end of file diff --git a/ffi/capi/bindings/js/ScriptWithExtensionsBorrowed.mjs b/ffi/capi/bindings/js/ScriptWithExtensionsBorrowed.mjs index 5a0a473b432..b27623bb02a 100644 --- a/ffi/capi/bindings/js/ScriptWithExtensionsBorrowed.mjs +++ b/ffi/capi/bindings/js/ScriptWithExtensionsBorrowed.mjs @@ -44,8 +44,8 @@ export class ScriptWithExtensionsBorrowed { return this.#ptr; } - getScriptVal(codePoint) { - const result = wasm.icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(this.ffiValue, codePoint); + getScriptVal(ch) { + const result = wasm.icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(this.ffiValue, ch); try { return result; @@ -54,11 +54,11 @@ export class ScriptWithExtensionsBorrowed { finally {} } - getScriptExtensionsVal(codePoint) { + getScriptExtensionsVal(ch) { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; - const result = wasm.icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(this.ffiValue, codePoint); + const result = wasm.icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(this.ffiValue, ch); try { return new ScriptExtensionsSet(diplomatRuntime.internalConstructor, result, [], aEdges); @@ -67,8 +67,8 @@ export class ScriptWithExtensionsBorrowed { finally {} } - hasScript(codePoint, script) { - const result = wasm.icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(this.ffiValue, codePoint, script); + hasScript(ch, script) { + const result = wasm.icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(this.ffiValue, ch, script); try { return result; diff --git a/ffi/capi/bindings/js/UnicodeSetData.d.ts b/ffi/capi/bindings/js/UnicodeSetData.d.ts index 6e7316d9f08..eb787d317c4 100644 --- a/ffi/capi/bindings/js/UnicodeSetData.d.ts +++ b/ffi/capi/bindings/js/UnicodeSetData.d.ts @@ -19,9 +19,9 @@ export class UnicodeSetData { get ffiValue(): pointer; - contains(s: string): boolean; + containsStr(s: string): boolean; - containsChar(cp: codepoint): boolean; + contains(cp: codepoint): boolean; static loadBasicEmoji(provider: DataProvider): UnicodeSetData; } \ No newline at end of file diff --git a/ffi/capi/bindings/js/UnicodeSetData.mjs b/ffi/capi/bindings/js/UnicodeSetData.mjs index bfc511f20c5..1bc02f0f225 100644 --- a/ffi/capi/bindings/js/UnicodeSetData.mjs +++ b/ffi/capi/bindings/js/UnicodeSetData.mjs @@ -46,12 +46,12 @@ export class UnicodeSetData { return this.#ptr; } - contains(s) { + containsStr(s) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); const sSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, s)); - const result = wasm.icu4x_UnicodeSetData_contains_mv1(this.ffiValue, ...sSlice.splat()); + const result = wasm.icu4x_UnicodeSetData_contains_str_mv1(this.ffiValue, ...sSlice.splat()); try { return result; @@ -62,8 +62,8 @@ export class UnicodeSetData { } } - containsChar(cp) { - const result = wasm.icu4x_UnicodeSetData_contains_char_mv1(this.ffiValue, cp); + contains(cp) { + const result = wasm.icu4x_UnicodeSetData_contains_mv1(this.ffiValue, cp); try { return result; diff --git a/ffi/capi/src/exemplar_chars.rs b/ffi/capi/src/exemplar_chars.rs index b9341c8c0b9..359de2d1e42 100644 --- a/ffi/capi/src/exemplar_chars.rs +++ b/ffi/capi/src/exemplar_chars.rs @@ -22,18 +22,19 @@ pub mod ffi { impl ExemplarCharacters { /// Checks whether the string is in the set. #[diplomat::rust_link( - icu::collections::codepointinvliststringlist::CodePointInversionListAndStringList::contains, + icu::collections::codepointinvliststringlist::CodePointInversionListAndStringList::contains_str, FnInStruct )] - pub fn contains(&self, s: &DiplomatStr) -> bool { + #[diplomat::attr(supports = method_overloading, rename = "contains")] + pub fn contains_str(&self, s: &DiplomatStr) -> bool { let Ok(s) = core::str::from_utf8(s) else { return false; }; - self.0.as_borrowed().contains(s) + self.0.as_borrowed().contains_str(s) } /// Checks whether the code point is in the set. #[diplomat::rust_link( - icu::collections::codepointinvliststringlist::CodePointInversionListAndStringList::contains_char, + icu::collections::codepointinvliststringlist::CodePointInversionListAndStringList::contains, FnInStruct )] #[diplomat::rust_link( @@ -41,7 +42,7 @@ pub mod ffi { FnInStruct, hidden )] - pub fn contains_char(&self, cp: DiplomatChar) -> bool { + pub fn contains(&self, cp: DiplomatChar) -> bool { self.0.as_borrowed().contains32(cp) } diff --git a/ffi/capi/src/properties_iter.rs b/ffi/capi/src/properties_iter.rs index 4d0e6280392..19e39054b45 100644 --- a/ffi/capi/src/properties_iter.rs +++ b/ffi/capi/src/properties_iter.rs @@ -10,7 +10,7 @@ pub mod ffi { use core::ops::RangeInclusive; /// Result of a single iteration of [`CodePointRangeIterator`]. - /// Logically can be considered to be an `Option>`, + /// Logically can be considered to be an `Option>`, /// /// `start` and `end` represent an inclusive range of code points [start, end], /// and `done` will be true if the iterator has already finished. The last contentful @@ -18,15 +18,17 @@ pub mod ffi { /// values if and only if `done=false`. #[diplomat::out] pub struct CodePointRangeIteratorResult { - pub start: u32, - pub end: u32, + pub start: DiplomatChar, + pub end: DiplomatChar, pub done: bool, } /// An iterator over code point ranges, produced by `CodePointSetData` or /// one of the `CodePointMapData` types #[diplomat::opaque] - pub struct CodePointRangeIterator<'a>(pub Box> + 'a>); + pub struct CodePointRangeIterator<'a>( + pub Box> + 'a>, + ); impl<'a> CodePointRangeIterator<'a> { /// Advance the iterator by one and return the next range. diff --git a/ffi/capi/src/properties_unisets.rs b/ffi/capi/src/properties_unisets.rs index 1f243dbe223..f38548f04c9 100644 --- a/ffi/capi/src/properties_unisets.rs +++ b/ffi/capi/src/properties_unisets.rs @@ -22,21 +22,22 @@ pub mod ffi { impl UnicodeSetData { /// Checks whether the string is in the set. - #[diplomat::rust_link(icu::properties::UnicodeSetDataBorrowed::contains, FnInStruct)] - pub fn contains(&self, s: &DiplomatStr) -> bool { + #[diplomat::rust_link(icu::properties::UnicodeSetDataBorrowed::contains_str, FnInStruct)] + #[diplomat::attr(supports = method_overloading, rename = "contains")] + pub fn contains_str(&self, s: &DiplomatStr) -> bool { let Ok(s) = core::str::from_utf8(s) else { return false; }; - self.0.as_borrowed().contains(s) + self.0.as_borrowed().contains_str(s) } /// Checks whether the code point is in the set. - #[diplomat::rust_link(icu::properties::UnicodeSetDataBorrowed::contains_char, FnInStruct)] + #[diplomat::rust_link(icu::properties::UnicodeSetDataBorrowed::contains, FnInStruct)] #[diplomat::rust_link( icu::properties::UnicodeSetDataBorrowed::contains32, FnInStruct, hidden )] - pub fn contains_char(&self, cp: DiplomatChar) -> bool { + pub fn contains(&self, cp: DiplomatChar) -> bool { self.0.as_borrowed().contains32(cp) } diff --git a/ffi/capi/src/script.rs b/ffi/capi/src/script.rs index d23f014d858..6b0427887f5 100644 --- a/ffi/capi/src/script.rs +++ b/ffi/capi/src/script.rs @@ -46,8 +46,13 @@ pub mod ffi { icu::properties::script::ScriptWithExtensionsBorrowed::get_script_val, FnInStruct )] - pub fn get_script_val(&self, code_point: u32) -> u16 { - self.0.as_borrowed().get_script_val(code_point).0 + #[diplomat::rust_link( + icu::properties::script::ScriptWithExtensionsBorrowed::get_script_val32, + FnInStruct, + hidden + )] + pub fn get_script_val(&self, ch: DiplomatChar) -> u16 { + self.0.as_borrowed().get_script_val32(ch).0 } /// Check if the Script_Extensions property of the given code point covers the given script @@ -55,10 +60,15 @@ pub mod ffi { icu::properties::script::ScriptWithExtensionsBorrowed::has_script, FnInStruct )] - pub fn has_script(&self, code_point: u32, script: u16) -> bool { + #[diplomat::rust_link( + icu::properties::script::ScriptWithExtensionsBorrowed::has_script32, + FnInStruct, + hidden + )] + pub fn has_script(&self, ch: DiplomatChar, script: u16) -> bool { self.0 .as_borrowed() - .has_script(code_point, icu_properties::props::Script(script)) + .has_script32(ch, icu_properties::props::Script(script)) } /// Borrow this object for a slightly faster variant with more operations @@ -94,27 +104,41 @@ pub mod ffi { icu::properties::script::ScriptWithExtensionsBorrowed::get_script_val, FnInStruct )] - pub fn get_script_val(&self, code_point: u32) -> u16 { - self.0.get_script_val(code_point).0 + /// Get the Script property value for a code point + #[diplomat::rust_link( + icu::properties::script::ScriptWithExtensionsBorrowed::get_script_val32, + FnInStruct, + hidden + )] + pub fn get_script_val(&self, ch: DiplomatChar) -> u16 { + self.0.get_script_val32(ch).0 } /// Get the Script property value for a code point #[diplomat::rust_link( icu::properties::script::ScriptWithExtensionsBorrowed::get_script_extensions_val, FnInStruct )] - pub fn get_script_extensions_val(&self, code_point: u32) -> Box> { - Box::new(ScriptExtensionsSet( - self.0.get_script_extensions_val(code_point), - )) + #[diplomat::rust_link( + icu::properties::script::ScriptWithExtensionsBorrowed::get_script_extensions_val32, + FnInStruct, + hidden + )] + pub fn get_script_extensions_val(&self, ch: DiplomatChar) -> Box> { + Box::new(ScriptExtensionsSet(self.0.get_script_extensions_val32(ch))) } /// Check if the Script_Extensions property of the given code point covers the given script #[diplomat::rust_link( icu::properties::script::ScriptWithExtensionsBorrowed::has_script, FnInStruct )] - pub fn has_script(&self, code_point: u32, script: u16) -> bool { + #[diplomat::rust_link( + icu::properties::script::ScriptWithExtensionsBorrowed::has_script32, + FnInStruct, + hidden + )] + pub fn has_script(&self, ch: DiplomatChar, script: u16) -> bool { self.0 - .has_script(code_point, icu_properties::props::Script(script)) + .has_script32(ch, icu_properties::props::Script(script)) } /// Build the CodePointSetData corresponding to a codepoints matching a particular script diff --git a/provider/source/src/properties/bin_uniset.rs b/provider/source/src/properties/bin_uniset.rs index 3b7be6a119a..dc01d0169ba 100644 --- a/provider/source/src/properties/bin_uniset.rs +++ b/provider/source/src/properties/bin_uniset.rs @@ -84,9 +84,9 @@ fn test_basic() { .unwrap(); assert!(!basic_emoji.contains32(0x0020)); - assert!(!basic_emoji.contains_char('\n')); - assert!(basic_emoji.contains_char('🦃')); // U+1F983 TURKEY - assert!(basic_emoji.contains("\u{1F983}")); - assert!(basic_emoji.contains("\u{1F6E4}\u{FE0F}")); // railway track - assert!(!basic_emoji.contains("\u{0033}\u{FE0F}\u{20E3}")); // Emoji_Keycap_Sequence, keycap 3 + assert!(!basic_emoji.contains('\n')); + assert!(basic_emoji.contains('🦃')); // U+1F983 TURKEY + assert!(basic_emoji.contains_str("\u{1F983}")); + assert!(basic_emoji.contains_str("\u{1F6E4}\u{FE0F}")); // railway track + assert!(!basic_emoji.contains_str("\u{0033}\u{FE0F}\u{20E3}")); // Emoji_Keycap_Sequence, keycap 3 } diff --git a/provider/source/src/properties/script.rs b/provider/source/src/properties/script.rs index fe984bc3fc6..77d94f22b0f 100644 --- a/provider/source/src/properties/script.rs +++ b/provider/source/src/properties/script.rs @@ -80,12 +80,12 @@ mod tests { icu::properties::script::ScriptWithExtensions::try_new_unstable(&provider).unwrap(); let swe = swe.as_borrowed(); - assert_eq!(swe.get_script_val('𐓐' as u32), Script::Osage); // U+104D0 OSAGE CAPITAL LETTER KHA - assert_eq!(swe.get_script_val('🥳' as u32), Script::Common); // U+1F973 FACE WITH PARTY HORN AND PARTY HAT - assert_eq!(swe.get_script_val(0x200D), Script::Inherited); // ZERO WIDTH JOINER - assert_eq!(swe.get_script_val('௫' as u32), Script::Tamil); // U+0BEB TAMIL DIGIT FIVE - assert_eq!(swe.get_script_val(0x11303), Script::Grantha); // GRANTHA SIGN VISARGA - assert_eq!(swe.get_script_val(0x30A0), Script::Common); // U+30A0 KATAKANA-HIRAGANA DOUBLE HYPHEN + assert_eq!(swe.get_script_val('𐓐'), Script::Osage); // U+104D0 OSAGE CAPITAL LETTER KHA + assert_eq!(swe.get_script_val('🥳'), Script::Common); // U+1F973 FACE WITH PARTY HORN AND PARTY HAT + assert_eq!(swe.get_script_val32(0x200D), Script::Inherited); // ZERO WIDTH JOINER + assert_eq!(swe.get_script_val('௫'), Script::Tamil); // U+0BEB TAMIL DIGIT FIVE + assert_eq!(swe.get_script_val32(0x11303), Script::Grantha); // GRANTHA SIGN VISARGA + assert_eq!(swe.get_script_val32(0x30A0), Script::Common); // U+30A0 KATAKANA-HIRAGANA DOUBLE HYPHEN } #[test] @@ -97,60 +97,60 @@ mod tests { let swe = swe.as_borrowed(); assert_eq!( - swe.get_script_extensions_val('𐓐' as u32) /* U+104D0 OSAGE CAPITAL LETTER KHA */ + swe.get_script_extensions_val('𐓐') /* U+104D0 OSAGE CAPITAL LETTER KHA */ .iter() .collect::>(), [Script::Osage] ); assert_eq!( - swe.get_script_extensions_val('🥳' as u32) /* U+1F973 FACE WITH PARTY HORN AND PARTY HAT */ + swe.get_script_extensions_val('🥳') /* U+1F973 FACE WITH PARTY HORN AND PARTY HAT */ .iter() .collect::>(), [Script::Common] ); assert_eq!( - swe.get_script_extensions_val(0x200D) // ZERO WIDTH JOINER + swe.get_script_extensions_val32(0x200D) // ZERO WIDTH JOINER .iter() .collect::>(), [Script::Inherited] ); assert_eq!( - swe.get_script_extensions_val('௫' as u32) // U+0BEB TAMIL DIGIT FIVE + swe.get_script_extensions_val('௫') // U+0BEB TAMIL DIGIT FIVE .iter() .collect::>(), [Script::Tamil, Script::Grantha] ); assert_eq!( - swe.get_script_extensions_val(0x11303) // GRANTHA SIGN VISARGA + swe.get_script_extensions_val32(0x11303) // GRANTHA SIGN VISARGA .iter() .collect::>(), [Script::Tamil, Script::Grantha] ); assert_eq!( - swe.get_script_extensions_val(0x30A0) // KATAKANA-HIRAGANA DOUBLE HYPHEN + swe.get_script_extensions_val32(0x30A0) // KATAKANA-HIRAGANA DOUBLE HYPHEN .iter() .collect::>(), [Script::Hiragana, Script::Katakana] ); assert_eq!( - swe.get_script_extensions_val(0x200D) // ZERO WIDTH JOINER + swe.get_script_extensions_val32(0x200D) // ZERO WIDTH JOINER .iter() .next(), Some(Script::Inherited) ); assert!(swe - .get_script_extensions_val(0x11303) // GRANTHA SIGN VISARGA + .get_script_extensions_val32(0x11303) // GRANTHA SIGN VISARGA .contains(&Script::Grantha)); assert!(!swe - .get_script_extensions_val(0x11303) // GRANTHA SIGN VISARGA + .get_script_extensions_val32(0x11303) // GRANTHA SIGN VISARGA .contains(&Script::Common)); // // Invalid code point assert_eq!( - swe.get_script_extensions_val(0x11_0000) // CODE_POINT_MAX + 1 is invalid + swe.get_script_extensions_val32(0x11_0000) // CODE_POINT_MAX + 1 is invalid .iter() .collect::>(), [Script::Unknown] @@ -165,71 +165,71 @@ mod tests { icu::properties::script::ScriptWithExtensions::try_new_unstable(&provider).unwrap(); let swe = swe.as_borrowed(); - assert!(swe.has_script('𐓐' as u32, Script::Osage)); - assert!(!swe.has_script('𐓐' as u32, Script::Common)); - assert!(!swe.has_script('𐓐' as u32, Script::Inherited)); + assert!(swe.has_script('𐓐', Script::Osage)); + assert!(!swe.has_script('𐓐', Script::Common)); + assert!(!swe.has_script('𐓐', Script::Inherited)); - assert!(swe.has_script('🥳' as u32, Script::Common)); - assert!(!swe.has_script('🥳' as u32, Script::Inherited)); + assert!(swe.has_script('🥳', Script::Common)); + assert!(!swe.has_script('🥳', Script::Inherited)); - assert!(!swe.has_script(0x200D, Script::Common)); - assert!(swe.has_script(0x200D, Script::Inherited)); + assert!(!swe.has_script32(0x200D, Script::Common)); + assert!(swe.has_script32(0x200D, Script::Inherited)); - assert!(swe.has_script('௫' as u32, Script::Tamil)); - assert!(swe.has_script('௫' as u32, Script::Grantha)); - assert!(!swe.has_script('௫' as u32, Script::Common)); - assert!(!swe.has_script('௫' as u32, Script::Inherited)); + assert!(swe.has_script('௫', Script::Tamil)); + assert!(swe.has_script('௫', Script::Grantha)); + assert!(!swe.has_script('௫', Script::Common)); + assert!(!swe.has_script('௫', Script::Inherited)); - assert!(swe.has_script(0x11303, Script::Tamil)); - assert!(swe.has_script(0x11303, Script::Grantha)); - assert!(!swe.has_script(0x11303, Script::Common)); - assert!(!swe.has_script(0x11303, Script::Inherited)); + assert!(swe.has_script32(0x11303, Script::Tamil)); + assert!(swe.has_script32(0x11303, Script::Grantha)); + assert!(!swe.has_script32(0x11303, Script::Common)); + assert!(!swe.has_script32(0x11303, Script::Inherited)); - assert!(swe.has_script(0x30A0, Script::Hiragana)); - assert!(swe.has_script(0x30A0, Script::Katakana)); - assert!(!swe.has_script(0x30A0, Script::Common)); - assert!(!swe.has_script(0x30A0, Script::Inherited)); + assert!(swe.has_script32(0x30A0, Script::Hiragana)); + assert!(swe.has_script32(0x30A0, Script::Katakana)); + assert!(!swe.has_script32(0x30A0, Script::Common)); + assert!(!swe.has_script32(0x30A0, Script::Inherited)); // U+0964 DEVANAGARI DANDA - assert!(!swe.has_script(0x0964, Script::Common)); - assert!(swe.has_script(0x0964, Script::Devanagari)); - assert!(swe.has_script(0x0964, Script::Bengali)); + assert!(!swe.has_script32(0x0964, Script::Common)); + assert!(swe.has_script32(0x0964, Script::Devanagari)); + assert!(swe.has_script32(0x0964, Script::Bengali)); // TestHasScript() test cases from ICU4J // U+063F ARABIC LETTER FARSI YEH WITH THREE DOTS ABOVE - assert!(!swe.has_script(0x063F, Script::Common)); - assert!(swe.has_script(0x063F, Script::Arabic)); // main Script value - assert!(!swe.has_script(0x063F, Script::Syriac)); - assert!(!swe.has_script(0x063F, Script::Thaana)); + assert!(!swe.has_script32(0x063F, Script::Common)); + assert!(swe.has_script32(0x063F, Script::Arabic)); // main Script value + assert!(!swe.has_script32(0x063F, Script::Syriac)); + assert!(!swe.has_script32(0x063F, Script::Thaana)); // U+0640 ARABIC TATWEEL - assert!(!swe.has_script(0x0640, Script::Common)); // main Script value - assert!(swe.has_script(0x0640, Script::Arabic)); - assert!(swe.has_script(0x0640, Script::Syriac)); - assert!(!swe.has_script(0x0640, Script::Thaana)); + assert!(!swe.has_script32(0x0640, Script::Common)); // main Script value + assert!(swe.has_script32(0x0640, Script::Arabic)); + assert!(swe.has_script32(0x0640, Script::Syriac)); + assert!(!swe.has_script32(0x0640, Script::Thaana)); // U+0650 ARABIC KASRA - assert!(!swe.has_script(0x0650, Script::Inherited)); // main Script value - assert!(swe.has_script(0x0650, Script::Arabic)); - assert!(swe.has_script(0x0650, Script::Syriac)); - assert!(!swe.has_script(0x0650, Script::Thaana)); + assert!(!swe.has_script32(0x0650, Script::Inherited)); // main Script value + assert!(swe.has_script32(0x0650, Script::Arabic)); + assert!(swe.has_script32(0x0650, Script::Syriac)); + assert!(!swe.has_script32(0x0650, Script::Thaana)); // U+0660 ARABIC-INDIC DIGIT ZERO - assert!(!swe.has_script(0x0660, Script::Common)); - assert!(swe.has_script(0x0660, Script::Arabic)); // main Script value - assert!(!swe.has_script(0x0660, Script::Syriac)); - assert!(swe.has_script(0x0660, Script::Thaana)); + assert!(!swe.has_script32(0x0660, Script::Common)); + assert!(swe.has_script32(0x0660, Script::Arabic)); // main Script value + assert!(!swe.has_script32(0x0660, Script::Syriac)); + assert!(swe.has_script32(0x0660, Script::Thaana)); // U+FDF2 ARABIC LIGATURE ALLAH ISOLATED FORM - assert!(!swe.has_script(0xFDF2, Script::Common)); - assert!(swe.has_script(0xFDF2, Script::Arabic)); // main Script value - assert!(!swe.has_script(0xFDF2, Script::Syriac)); - assert!(swe.has_script(0xFDF2, Script::Thaana)); + assert!(!swe.has_script32(0xFDF2, Script::Common)); + assert!(swe.has_script32(0xFDF2, Script::Arabic)); // main Script value + assert!(!swe.has_script32(0xFDF2, Script::Syriac)); + assert!(swe.has_script32(0xFDF2, Script::Thaana)); // The ICU4J comment for this test says: // An unguarded implementation might go into an infinite loop. - assert!(!swe.has_script(0x0640, Script(0xAFFE))); + assert!(!swe.has_script32(0x0640, Script(0xAFFE))); } #[test] diff --git a/tutorials/cpp/properties.cpp b/tutorials/cpp/properties.cpp index 7787e797314..4d417995e3b 100644 --- a/tutorials/cpp/properties.cpp +++ b/tutorials/cpp/properties.cpp @@ -96,7 +96,7 @@ int main() { std::unique_ptr basic_emoji = UnicodeSetData::load_basic_emoji(*dp.get()).ok().value(); std::string letter = u8"hello"; - if (!basic_emoji->contains_char(U'🔥')) { + if (!basic_emoji->contains(U'🔥')) { std::cout << "Character 🔥 not found in Basic_Emoji set" << std::endl; result = 1; } @@ -105,7 +105,7 @@ int main() { std::cout << "String \"🗺️\" (U+1F5FA U+FE0F) not found in Basic_Emoji set" << std::endl; result = 1; } - if (basic_emoji->contains_char(U'a')) { + if (basic_emoji->contains(U'a')) { std::cout << "Character a found in Basic_Emoji set" << std::endl; result = 1; } @@ -122,7 +122,7 @@ int main() { } std::unique_ptr locale = Locale::from_string("bn").ok().value(); std::unique_ptr exemplars = ExemplarCharacters::try_new_main(*dp.get(), *locale.get()).ok().value(); - if (!exemplars->contains_char(U'ব')) { + if (!exemplars->contains(U'ব')) { std::cout << "Character 'ব' not found in Bangla exemplar chars set" << std::endl; result = 1; } @@ -131,7 +131,7 @@ int main() { std::cout << "String \"ক্ষ\" (U+0995U+09CDU+09B7) not found in Bangla exemplar chars set" << std::endl; result = 1; } - if (exemplars->contains_char(U'a')) { + if (exemplars->contains(U'a')) { std::cout << "Character a found in Bangla exemplar chars set" << std::endl; result = 1; }