1 // This file is part of ICU4X. For terms of use, please see the file 2 // called LICENSE at the top level of the ICU4X source tree 3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). 4 5 #[diplomat::bridge] 6 #[diplomat::abi_rename = "icu4x_{0}_mv1"] 7 #[diplomat::attr(auto, namespace = "icu4x")] 8 pub mod ffi { 9 use alloc::boxed::Box; 10 #[cfg(any(feature = "compiled_data", feature = "buffer_provider"))] 11 use icu_properties::props::{ 12 BidiClass, CanonicalCombiningClass, EastAsianWidth, GeneralCategory, GraphemeClusterBreak, 13 HangulSyllableType, IndicSyllabicCategory, JoiningType, LineBreak, Script, SentenceBreak, 14 WordBreak, 15 }; 16 17 use crate::properties_enums::ffi::GeneralCategoryGroup; 18 use crate::properties_iter::ffi::CodePointRangeIterator; 19 use crate::properties_sets::ffi::CodePointSetData; 20 #[cfg(feature = "buffer_provider")] 21 use crate::{errors::ffi::DataError, provider::ffi::DataProvider}; 22 23 #[diplomat::opaque] 24 /// An ICU4X Unicode Map Property object, capable of querying whether a code point (key) to obtain the Unicode property value, for a specific Unicode property. 25 /// 26 /// For properties whose values fit into 8 bits. 27 #[diplomat::rust_link(icu::properties, Mod)] 28 #[diplomat::rust_link(icu::properties::CodePointMapData, Struct)] 29 #[diplomat::rust_link(icu::properties::CodePointMapDataBorrowed, Struct)] 30 #[diplomat::rust_link(icu::properties::CodePointMapData::new, FnInStruct, hidden)] 31 #[diplomat::rust_link(icu::properties::CodePointMapDataBorrowed::new, FnInStruct, hidden)] 32 #[diplomat::rust_link( 33 icu::properties::CodePointMapData::try_into_converted, 34 FnInStruct, 35 hidden 36 )] 37 pub struct CodePointMapData8(icu_properties::CodePointMapData<u8>); 38 39 #[cfg(any(feature = "compiled_data", feature = "buffer_provider"))] convert_8<P: icu_collections::codepointtrie::TrieValue>( data: icu_properties::CodePointMapData<P>, ) -> Box<CodePointMapData8>40 fn convert_8<P: icu_collections::codepointtrie::TrieValue>( 41 data: icu_properties::CodePointMapData<P>, 42 ) -> Box<CodePointMapData8> { 43 #[allow(clippy::unwrap_used)] // infallible for the chosen properties 44 Box::new(CodePointMapData8( 45 data.try_into_converted().map_err(|_| ()).unwrap(), 46 )) 47 } 48 49 impl CodePointMapData8 { 50 /// Gets the value for a code point. 51 #[diplomat::rust_link(icu::properties::CodePointMapDataBorrowed::get, FnInStruct)] 52 #[diplomat::rust_link(icu::properties::CodePointMapDataBorrowed::get32, FnInStruct, hidden)] 53 #[diplomat::attr(auto, indexer)] get(&self, cp: DiplomatChar) -> u854 pub fn get(&self, cp: DiplomatChar) -> u8 { 55 self.0.as_borrowed().get32(cp) 56 } 57 58 /// Produces an iterator over ranges of code points that map to `value` 59 #[diplomat::rust_link( 60 icu::properties::CodePointMapDataBorrowed::iter_ranges_for_value, 61 FnInStruct 62 )] iter_ranges_for_value<'a>(&'a self, value: u8) -> Box<CodePointRangeIterator<'a>>63 pub fn iter_ranges_for_value<'a>(&'a self, value: u8) -> Box<CodePointRangeIterator<'a>> { 64 Box::new(CodePointRangeIterator(Box::new( 65 self.0.as_borrowed().iter_ranges_for_value(value), 66 ))) 67 } 68 69 /// Produces an iterator over ranges of code points that do not map to `value` 70 #[diplomat::rust_link( 71 icu::properties::CodePointMapDataBorrowed::iter_ranges_for_value_complemented, 72 FnInStruct 73 )] iter_ranges_for_value_complemented<'a>( &'a self, value: u8, ) -> Box<CodePointRangeIterator<'a>>74 pub fn iter_ranges_for_value_complemented<'a>( 75 &'a self, 76 value: u8, 77 ) -> Box<CodePointRangeIterator<'a>> { 78 Box::new(CodePointRangeIterator(Box::new( 79 self.0 80 .as_borrowed() 81 .iter_ranges_for_value_complemented(value), 82 ))) 83 } 84 85 /// Given a mask value (the nth bit marks property value = n), produce an iterator over ranges of code points 86 /// whose property values are contained in the mask. 87 /// 88 /// The main mask property supported is that for General_Category, which can be obtained via `general_category_to_mask()` or 89 /// by using `GeneralCategoryNameToMaskMapper` 90 /// 91 /// Should only be used on maps for properties with values less than 32 (like Generak_Category), 92 /// other maps will have unpredictable results 93 #[diplomat::rust_link( 94 icu::properties::CodePointMapDataBorrowed::iter_ranges_for_group, 95 FnInStruct 96 )] iter_ranges_for_group<'a>( &'a self, group: GeneralCategoryGroup, ) -> Box<CodePointRangeIterator<'a>>97 pub fn iter_ranges_for_group<'a>( 98 &'a self, 99 group: GeneralCategoryGroup, 100 ) -> Box<CodePointRangeIterator<'a>> { 101 let ranges = self 102 .0 103 .as_borrowed() 104 .iter_ranges_mapped(move |v| { 105 let val_mask = 1_u32.checked_shl(v.into()).unwrap_or(0); 106 val_mask & group.mask != 0 107 }) 108 .filter(|v| v.value) 109 .map(|v| v.range); 110 Box::new(CodePointRangeIterator(Box::new(ranges))) 111 } 112 113 /// Gets a [`CodePointSetData`] representing all entries in this map that map to the given value 114 #[diplomat::rust_link( 115 icu::properties::CodePointMapDataBorrowed::get_set_for_value, 116 FnInStruct 117 )] get_set_for_value(&self, value: u8) -> Box<CodePointSetData>118 pub fn get_set_for_value(&self, value: u8) -> Box<CodePointSetData> { 119 Box::new(CodePointSetData( 120 self.0.as_borrowed().get_set_for_value(value), 121 )) 122 } 123 124 /// Create a map for the `General_Category` property, using compiled data. 125 #[diplomat::rust_link(icu::properties::props::GeneralCategory, Enum)] 126 #[diplomat::attr(auto, named_constructor = "general_category")] 127 #[cfg(feature = "compiled_data")] create_general_category() -> Box<CodePointMapData8>128 pub fn create_general_category() -> Box<CodePointMapData8> { 129 convert_8(icu_properties::CodePointMapData::<GeneralCategory>::new().static_to_owned()) 130 } 131 132 /// Create a map for the `General_Category` property, using a particular data source 133 #[diplomat::rust_link(icu::properties::props::GeneralCategory, Enum)] 134 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "general_category_with_provider")] 135 #[cfg(feature = "buffer_provider")] create_general_category_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>136 pub fn create_general_category_with_provider( 137 provider: &DataProvider, 138 ) -> Result<Box<CodePointMapData8>, DataError> { 139 Ok(convert_8(icu_properties::CodePointMapData::< 140 GeneralCategory, 141 >::try_new_unstable( 142 &provider.get_unstable()? 143 )?)) 144 } 145 146 /// Create a map for the `Bidi_Class` property, using compiled data. 147 #[diplomat::rust_link(icu::properties::props::BidiClass, Struct)] 148 #[diplomat::attr(auto, named_constructor = "bidi_class")] 149 #[cfg(feature = "compiled_data")] create_bidi_class() -> Box<CodePointMapData8>150 pub fn create_bidi_class() -> Box<CodePointMapData8> { 151 convert_8(icu_properties::CodePointMapData::<BidiClass>::new().static_to_owned()) 152 } 153 154 /// Create a map for the `Bidi_Class` property, using a particular data source. 155 #[diplomat::rust_link(icu::properties::props::BidiClass, Struct)] 156 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "bidi_class_with_provider")] 157 #[cfg(feature = "buffer_provider")] create_bidi_class_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>158 pub fn create_bidi_class_with_provider( 159 provider: &DataProvider, 160 ) -> Result<Box<CodePointMapData8>, DataError> { 161 Ok(convert_8( 162 icu_properties::CodePointMapData::<BidiClass>::try_new_unstable( 163 &provider.get_unstable()?, 164 )?, 165 )) 166 } 167 /// Create a map for the `East_Asian_Width` property, using compiled data. 168 #[diplomat::rust_link(icu::properties::props::EastAsianWidth, Struct)] 169 #[diplomat::attr(auto, named_constructor = "east_asian_width")] 170 #[cfg(feature = "compiled_data")] create_east_asian_width() -> Box<CodePointMapData8>171 pub fn create_east_asian_width() -> Box<CodePointMapData8> { 172 convert_8(icu_properties::CodePointMapData::<EastAsianWidth>::new().static_to_owned()) 173 } 174 175 /// Create a map for the `East_Asian_Width` property, using a particular data source. 176 #[diplomat::rust_link(icu::properties::props::EastAsianWidth, Struct)] 177 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "east_asian_width_with_provider")] 178 #[cfg(feature = "buffer_provider")] create_east_asian_width_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>179 pub fn create_east_asian_width_with_provider( 180 provider: &DataProvider, 181 ) -> Result<Box<CodePointMapData8>, DataError> { 182 Ok(convert_8( 183 icu_properties::CodePointMapData::<EastAsianWidth>::try_new_unstable( 184 &provider.get_unstable()?, 185 )?, 186 )) 187 } 188 /// Create a map for the `Hangul_Syllable_Type` property, using compiled data. 189 #[diplomat::rust_link(icu::properties::props::HangulSyllableType, Struct)] 190 #[diplomat::attr(auto, named_constructor = "hangul_syllable_type")] 191 #[cfg(feature = "compiled_data")] create_hangul_syllable_type() -> Box<CodePointMapData8>192 pub fn create_hangul_syllable_type() -> Box<CodePointMapData8> { 193 convert_8( 194 icu_properties::CodePointMapData::<HangulSyllableType>::new().static_to_owned(), 195 ) 196 } 197 /// Create a map for the `Hangul_Syllable_Type` property, using a particular data source. 198 #[diplomat::rust_link(icu::properties::props::HangulSyllableType, Struct)] 199 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "hangul_syllable_type_with_provider")] 200 #[cfg(feature = "buffer_provider")] create_hangul_syllable_type_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>201 pub fn create_hangul_syllable_type_with_provider( 202 provider: &DataProvider, 203 ) -> Result<Box<CodePointMapData8>, DataError> { 204 Ok(convert_8(icu_properties::CodePointMapData::< 205 HangulSyllableType, 206 >::try_new_unstable( 207 &provider.get_unstable()? 208 )?)) 209 } 210 /// Create a map for the `Indic_Syllabic_Property` property, using compiled data. 211 #[diplomat::rust_link(icu::properties::props::IndicSyllabicCategory, Struct)] 212 #[diplomat::attr(auto, named_constructor = "indic_syllabic_category")] 213 #[cfg(feature = "compiled_data")] create_indic_syllabic_category() -> Box<CodePointMapData8>214 pub fn create_indic_syllabic_category() -> Box<CodePointMapData8> { 215 convert_8( 216 icu_properties::CodePointMapData::<IndicSyllabicCategory>::new().static_to_owned(), 217 ) 218 } 219 /// Create a map for the `Indic_Syllabic_Property` property, using a particular data source. 220 #[diplomat::rust_link(icu::properties::props::IndicSyllabicCategory, Struct)] 221 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "indic_syllabic_category_with_provider")] 222 #[cfg(feature = "buffer_provider")] create_indic_syllabic_category_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>223 pub fn create_indic_syllabic_category_with_provider( 224 provider: &DataProvider, 225 ) -> Result<Box<CodePointMapData8>, DataError> { 226 Ok(convert_8(icu_properties::CodePointMapData::< 227 IndicSyllabicCategory, 228 >::try_new_unstable( 229 &provider.get_unstable()? 230 )?)) 231 } 232 /// Create a map for the `Line_Break` property, using compiled data. 233 #[diplomat::rust_link(icu::properties::props::LineBreak, Struct)] 234 #[diplomat::attr(auto, named_constructor = "line_break")] 235 #[cfg(feature = "compiled_data")] create_line_break() -> Box<CodePointMapData8>236 pub fn create_line_break() -> Box<CodePointMapData8> { 237 convert_8(icu_properties::CodePointMapData::<LineBreak>::new().static_to_owned()) 238 } 239 /// Create a map for the `Line_Break` property, using a particular data source. 240 #[diplomat::rust_link(icu::properties::props::LineBreak, Struct)] 241 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "line_break_with_provider")] 242 #[cfg(feature = "buffer_provider")] create_line_break_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>243 pub fn create_line_break_with_provider( 244 provider: &DataProvider, 245 ) -> Result<Box<CodePointMapData8>, DataError> { 246 Ok(convert_8( 247 icu_properties::CodePointMapData::<LineBreak>::try_new_unstable( 248 &provider.get_unstable()?, 249 )?, 250 )) 251 } 252 /// Create a map for the `Grapheme_Cluster_Break` property, using compiled data. 253 #[diplomat::rust_link(icu::properties::props::GraphemeClusterBreak, Struct)] 254 #[diplomat::attr(auto, named_constructor = "grapheme_cluster_break")] 255 #[cfg(feature = "compiled_data")] create_grapheme_cluster_break() -> Box<CodePointMapData8>256 pub fn create_grapheme_cluster_break() -> Box<CodePointMapData8> { 257 convert_8( 258 icu_properties::CodePointMapData::<GraphemeClusterBreak>::new().static_to_owned(), 259 ) 260 } 261 /// Create a map for the `Grapheme_Cluster_Break` property, using a particular data source. 262 #[diplomat::rust_link(icu::properties::props::GraphemeClusterBreak, Struct)] 263 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "grapheme_cluster_break_with_provider")] 264 #[cfg(feature = "buffer_provider")] create_grapheme_cluster_break_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>265 pub fn create_grapheme_cluster_break_with_provider( 266 provider: &DataProvider, 267 ) -> Result<Box<CodePointMapData8>, DataError> { 268 Ok(convert_8(icu_properties::CodePointMapData::< 269 GraphemeClusterBreak, 270 >::try_new_unstable( 271 &provider.get_unstable()? 272 )?)) 273 } 274 /// Create a map for the `Word_Break` property, using compiled data. 275 #[diplomat::rust_link(icu::properties::props::WordBreak, Struct)] 276 #[diplomat::attr(auto, named_constructor = "word_break")] 277 #[cfg(feature = "compiled_data")] create_word_break() -> Box<CodePointMapData8>278 pub fn create_word_break() -> Box<CodePointMapData8> { 279 convert_8(icu_properties::CodePointMapData::<WordBreak>::new().static_to_owned()) 280 } 281 /// Create a map for the `Word_Break` property, using a particular data source. 282 #[diplomat::rust_link(icu::properties::props::WordBreak, Struct)] 283 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "word_break_with_provider")] 284 #[cfg(feature = "buffer_provider")] create_word_break_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>285 pub fn create_word_break_with_provider( 286 provider: &DataProvider, 287 ) -> Result<Box<CodePointMapData8>, DataError> { 288 Ok(convert_8( 289 icu_properties::CodePointMapData::<WordBreak>::try_new_unstable( 290 &provider.get_unstable()?, 291 )?, 292 )) 293 } 294 /// Create a map for the `Sentence_Break` property, using compiled data. 295 #[diplomat::rust_link(icu::properties::props::SentenceBreak, Struct)] 296 #[diplomat::attr(auto, named_constructor = "sentence_break")] 297 #[cfg(feature = "compiled_data")] create_sentence_break() -> Box<CodePointMapData8>298 pub fn create_sentence_break() -> Box<CodePointMapData8> { 299 convert_8(icu_properties::CodePointMapData::<SentenceBreak>::new().static_to_owned()) 300 } 301 /// Create a map for the `Sentence_Break` property, using a particular data source. 302 #[diplomat::rust_link(icu::properties::props::SentenceBreak, Struct)] 303 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "sentence_break_with_provider")] 304 #[cfg(feature = "buffer_provider")] create_sentence_break_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>305 pub fn create_sentence_break_with_provider( 306 provider: &DataProvider, 307 ) -> Result<Box<CodePointMapData8>, DataError> { 308 Ok(convert_8( 309 icu_properties::CodePointMapData::<SentenceBreak>::try_new_unstable( 310 &provider.get_unstable()?, 311 )?, 312 )) 313 } 314 /// Create a map for the `Joining_Type` property, using compiled data. 315 #[diplomat::rust_link(icu::properties::props::JoiningType, Struct)] 316 #[diplomat::attr(auto, named_constructor = "joining_type")] 317 #[cfg(feature = "compiled_data")] create_joining_type() -> Box<CodePointMapData8>318 pub fn create_joining_type() -> Box<CodePointMapData8> { 319 convert_8(icu_properties::CodePointMapData::<JoiningType>::new().static_to_owned()) 320 } 321 322 /// Create a map for the `Joining_Type` property, using a particular data source. 323 #[diplomat::rust_link(icu::properties::props::JoiningType, Struct)] 324 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "joining_type_with_provider")] 325 #[cfg(feature = "buffer_provider")] create_joining_type_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>326 pub fn create_joining_type_with_provider( 327 provider: &DataProvider, 328 ) -> Result<Box<CodePointMapData8>, DataError> { 329 Ok(convert_8( 330 icu_properties::CodePointMapData::<JoiningType>::try_new_unstable( 331 &provider.get_unstable()?, 332 )?, 333 )) 334 } 335 /// Create a map for the `Canonical_Combining_Class` property, using compiled data. 336 #[diplomat::rust_link(icu::properties::props::CanonicalCombiningClass, Struct)] 337 #[diplomat::attr(auto, named_constructor = "canonical_combining_class")] 338 #[cfg(feature = "compiled_data")] create_canonical_combining_class() -> Box<CodePointMapData8>339 pub fn create_canonical_combining_class() -> Box<CodePointMapData8> { 340 convert_8( 341 icu_properties::CodePointMapData::<CanonicalCombiningClass>::new() 342 .static_to_owned(), 343 ) 344 } 345 /// Create a map for the `Canonical_Combining_Class` property, using a particular data source. 346 #[diplomat::rust_link(icu::properties::props::CanonicalCombiningClass, Struct)] 347 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "canonical_combining_class_with_provider")] 348 #[cfg(feature = "buffer_provider")] create_canonical_combining_class_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData8>, DataError>349 pub fn create_canonical_combining_class_with_provider( 350 provider: &DataProvider, 351 ) -> Result<Box<CodePointMapData8>, DataError> { 352 Ok(convert_8(icu_properties::CodePointMapData::< 353 CanonicalCombiningClass, 354 >::try_new_unstable( 355 &provider.get_unstable()? 356 )?)) 357 } 358 } 359 360 #[diplomat::opaque] 361 /// An ICU4X Unicode Map Property object, capable of querying whether a code point (key) to obtain the Unicode property value, for a specific Unicode property. 362 /// 363 /// For properties whose values fit into 16 bits. 364 #[diplomat::rust_link(icu::properties, Mod)] 365 #[diplomat::rust_link(icu::properties::CodePointMapData, Struct)] 366 #[diplomat::rust_link(icu::properties::CodePointMapDataBorrowed, Struct)] 367 pub struct CodePointMapData16(icu_properties::CodePointMapData<u16>); 368 369 impl CodePointMapData16 { 370 /// Gets the value for a code point. 371 #[diplomat::rust_link(icu::properties::props::CodePointMapDataBorrowed::get, FnInStruct)] 372 #[diplomat::rust_link(icu::properties::CodePointMapDataBorrowed::get32, FnInStruct, hidden)] 373 #[diplomat::attr(auto, indexer)] get(&self, cp: DiplomatChar) -> u16374 pub fn get(&self, cp: DiplomatChar) -> u16 { 375 self.0.as_borrowed().get32(cp) 376 } 377 378 /// Produces an iterator over ranges of code points that map to `value` 379 #[diplomat::rust_link( 380 icu::properties::CodePointMapDataBorrowed::iter_ranges_for_value, 381 FnInStruct 382 )] iter_ranges_for_value<'a>(&'a self, value: u16) -> Box<CodePointRangeIterator<'a>>383 pub fn iter_ranges_for_value<'a>(&'a self, value: u16) -> Box<CodePointRangeIterator<'a>> { 384 Box::new(CodePointRangeIterator(Box::new( 385 self.0.as_borrowed().iter_ranges_for_value(value), 386 ))) 387 } 388 389 /// Produces an iterator over ranges of code points that do not map to `value` 390 #[diplomat::rust_link( 391 icu::properties::CodePointMapDataBorrowed::iter_ranges_for_value_complemented, 392 FnInStruct 393 )] iter_ranges_for_value_complemented<'a>( &'a self, value: u16, ) -> Box<CodePointRangeIterator<'a>>394 pub fn iter_ranges_for_value_complemented<'a>( 395 &'a self, 396 value: u16, 397 ) -> Box<CodePointRangeIterator<'a>> { 398 Box::new(CodePointRangeIterator(Box::new( 399 self.0 400 .as_borrowed() 401 .iter_ranges_for_value_complemented(value), 402 ))) 403 } 404 405 /// Gets a [`CodePointSetData`] representing all entries in this map that map to the given value 406 #[diplomat::rust_link( 407 icu::properties::CodePointMapDataBorrowed::get_set_for_value, 408 FnInStruct 409 )] get_set_for_value(&self, value: u16) -> Box<CodePointSetData>410 pub fn get_set_for_value(&self, value: u16) -> Box<CodePointSetData> { 411 Box::new(CodePointSetData( 412 self.0.as_borrowed().get_set_for_value(value), 413 )) 414 } 415 416 /// Create a map for the `Script` property, using compiled data. 417 #[diplomat::rust_link(icu::properties::props::Script, Struct)] 418 #[diplomat::attr(auto, named_constructor = "script")] 419 #[cfg(feature = "compiled_data")] create_script() -> Box<CodePointMapData16>420 pub fn create_script() -> Box<CodePointMapData16> { 421 #[allow(clippy::unwrap_used)] // script is a 16-bit property 422 let data = icu_properties::CodePointMapData::<Script>::new() 423 .static_to_owned() 424 .try_into_converted() 425 .map_err(|_| ()) 426 .unwrap(); 427 Box::new(CodePointMapData16(data)) 428 } 429 430 /// Create a map for the `Script` property, using a particular data source. 431 #[diplomat::rust_link(icu::properties::props::Script, Struct)] 432 #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "script_with_provider")] 433 #[cfg(feature = "buffer_provider")] create_script_with_provider( provider: &DataProvider, ) -> Result<Box<CodePointMapData16>, DataError>434 pub fn create_script_with_provider( 435 provider: &DataProvider, 436 ) -> Result<Box<CodePointMapData16>, DataError> { 437 #[allow(clippy::unwrap_used)] // script is a 16-bit property 438 Ok(Box::new(CodePointMapData16( 439 icu_properties::CodePointMapData::<Script>::try_new_unstable( 440 &provider.get_unstable()?, 441 )? 442 .try_into_converted() 443 .map_err(|_| ()) 444 .unwrap(), 445 ))) 446 } 447 } 448 } 449