pub fn load_for_ecma262(
name: &str,
) -> Result<CodePointSetDataBorrowed<'static>, PropertiesError>Expand description
Returns a type capable of looking up values for a property specified as a string, as long as it is a binary property listed in ECMA-262, using strict matching on the names in the spec.
This handles every property required by ECMA-262 /u regular expressions, except for:
ScriptandGeneral_Category: handle these directly withmaps::load_general_category()andmaps::load_script(). using property values parsed viaGeneralCategory::get_name_to_enum_mapper()andScript::get_name_to_enum_mapper()if necessary.Script_Extensions: handle this directly using APIs fromcrate::script, likescript::load_script_with_extensions_unstable()General_Categorymask values: Handle this alongsideGeneral_CategoryusingGeneralCategoryGroup, using property values parsed viaGeneralCategoryGroup::get_name_to_enum_mapper()if necessaryAssigned,All, andASCIIpseudoproperties: Handle these using their equivalent sets:Anycan be expressed as the range[\u{0}-\u{10FFFF}]Assignedcan be expressed as the inverse of the setgc=Cn(i.e.,\P{gc=Cn}).ASCIIcan be expressed as the range[\u{0}-\u{7F}]
General_Categoryproperty values can themselves be treated like properties using a shorthand in ECMA262, simply create the correspondingGeneralCategoryset.
✨ Enabled with the compiled_data Cargo feature.
use icu::properties::sets;
let emoji = sets::load_for_ecma262("Emoji").expect("loading data failed");
assert!(emoji.contains('🔥')); // U+1F525 FIRE
assert!(!emoji.contains('V'));