pub struct CodePointSetData { /* private fields */ }Expand description
A set of Unicode code points. Access its data via the borrowed version,
CodePointSetDataBorrowed.
§Example
use icu::properties::CodePointSetData;
use icu::properties::props::Alphabetic;
let alphabetic = CodePointSetData::new::<Alphabetic>();
assert!(!alphabetic.contains('3'));
assert!(!alphabetic.contains('੩')); // U+0A69 GURMUKHI DIGIT THREE
assert!(alphabetic.contains('A'));
assert!(alphabetic.contains('Ä')); // U+00C4 LATIN CAPITAL LETTER A WITH DIAERESISImplementations§
Source§impl CodePointSetData
impl CodePointSetData
Sourcepub const fn new<P: BinaryProperty>() -> CodePointSetDataBorrowed<'static>
pub const fn new<P: BinaryProperty>() -> CodePointSetDataBorrowed<'static>
Creates a new CodePointSetDataBorrowed for a BinaryProperty.
✨ Enabled with the compiled_data Cargo feature.
Sourcepub fn try_new_unstable<P: BinaryProperty>(
provider: &(impl DataProvider<P::DataMarker> + ?Sized),
) -> Result<CodePointSetData, DataError>
pub fn try_new_unstable<P: BinaryProperty>( provider: &(impl DataProvider<P::DataMarker> + ?Sized), ) -> Result<CodePointSetData, DataError>
A version of Self::new that uses custom data provided by a DataProvider.
Sourcepub fn as_borrowed(&self) -> CodePointSetDataBorrowed<'_>
pub fn as_borrowed(&self) -> CodePointSetDataBorrowed<'_>
Construct a borrowed version of this type that can be queried.
This owned version if returned by functions that use a runtime data provider.
Sourcepub fn from_code_point_inversion_list(
set: CodePointInversionList<'static>,
) -> Self
pub fn from_code_point_inversion_list( set: CodePointInversionList<'static>, ) -> Self
Construct a new owned CodePointInversionList
Sourcepub fn as_code_point_inversion_list(
&self,
) -> Option<&CodePointInversionList<'_>>
pub fn as_code_point_inversion_list( &self, ) -> Option<&CodePointInversionList<'_>>
Convert this type to a CodePointInversionList as a borrowed value.
The data backing this is extensible and supports multiple implementations.
Currently it is always CodePointInversionList; however in the future more backends may be
added, and users may select which at data generation time.
This method returns an Option in order to return None when the backing data provider
cannot return a CodePointInversionList, or cannot do so within the expected constant time
constraint.
Sourcepub fn to_code_point_inversion_list(&self) -> CodePointInversionList<'_>
pub fn to_code_point_inversion_list(&self) -> CodePointInversionList<'_>
Convert this type to a CodePointInversionList, borrowing if possible,
otherwise allocating a new CodePointInversionList.
The data backing this is extensible and supports multiple implementations.
Currently it is always CodePointInversionList; however in the future more backends may be
added, and users may select which at data generation time.
The performance of the conversion to this specific return type will vary
depending on the data structure that is backing self.
Source§impl CodePointSetData
impl CodePointSetData
Sourcepub fn new_for_ecma262(prop: &[u8]) -> Option<CodePointSetDataBorrowed<'static>>
pub fn new_for_ecma262(prop: &[u8]) -> Option<CodePointSetDataBorrowed<'static>>
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 using property values parsed viaPropertyParser<GeneralCategory>andPropertyParser<Script>if necessary.Script_Extensions: handle this directly using APIs fromcrate::script::ScriptWithExtensionsGeneral_Categorymask values: Handle this alongsideGeneral_CategoryusingGeneralCategoryGroup, using property values parsed viaPropertyParser<GeneralCategory>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::CodePointSetData;
let emoji = CodePointSetData::new_for_ecma262(b"Emoji")
.expect("is an ECMA-262 property");
assert!(emoji.contains('🔥')); // U+1F525 FIRE
assert!(!emoji.contains('V'));Sourcepub fn try_new_for_ecma262_unstable<P>(
provider: &P,
prop: &[u8],
) -> Option<Result<Self, DataError>>where
P: ?Sized + DataProvider<PropertyBinaryAsciiHexDigitV1> + DataProvider<PropertyBinaryAlphabeticV1> + DataProvider<PropertyBinaryBidiControlV1> + DataProvider<PropertyBinaryBidiMirroredV1> + DataProvider<PropertyBinaryCaseIgnorableV1> + DataProvider<PropertyBinaryCasedV1> + DataProvider<PropertyBinaryChangesWhenCasefoldedV1> + DataProvider<PropertyBinaryChangesWhenCasemappedV1> + DataProvider<PropertyBinaryChangesWhenLowercasedV1> + DataProvider<PropertyBinaryChangesWhenNfkcCasefoldedV1> + DataProvider<PropertyBinaryChangesWhenTitlecasedV1> + DataProvider<PropertyBinaryChangesWhenUppercasedV1> + DataProvider<PropertyBinaryDashV1> + DataProvider<PropertyBinaryDefaultIgnorableCodePointV1> + DataProvider<PropertyBinaryDeprecatedV1> + DataProvider<PropertyBinaryDiacriticV1> + DataProvider<PropertyBinaryEmojiV1> + DataProvider<PropertyBinaryEmojiComponentV1> + DataProvider<PropertyBinaryEmojiModifierV1> + DataProvider<PropertyBinaryEmojiModifierBaseV1> + DataProvider<PropertyBinaryEmojiPresentationV1> + DataProvider<PropertyBinaryExtendedPictographicV1> + DataProvider<PropertyBinaryExtenderV1> + DataProvider<PropertyBinaryGraphemeBaseV1> + DataProvider<PropertyBinaryGraphemeExtendV1> + DataProvider<PropertyBinaryHexDigitV1> + DataProvider<PropertyBinaryIdsBinaryOperatorV1> + DataProvider<PropertyBinaryIdsTrinaryOperatorV1> + DataProvider<PropertyBinaryIdContinueV1> + DataProvider<PropertyBinaryIdStartV1> + DataProvider<PropertyBinaryIdeographicV1> + DataProvider<PropertyBinaryJoinControlV1> + DataProvider<PropertyBinaryLogicalOrderExceptionV1> + DataProvider<PropertyBinaryLowercaseV1> + DataProvider<PropertyBinaryMathV1> + DataProvider<PropertyBinaryNoncharacterCodePointV1> + DataProvider<PropertyBinaryPatternSyntaxV1> + DataProvider<PropertyBinaryPatternWhiteSpaceV1> + DataProvider<PropertyBinaryQuotationMarkV1> + DataProvider<PropertyBinaryRadicalV1> + DataProvider<PropertyBinaryRegionalIndicatorV1> + DataProvider<PropertyBinarySentenceTerminalV1> + DataProvider<PropertyBinarySoftDottedV1> + DataProvider<PropertyBinaryTerminalPunctuationV1> + DataProvider<PropertyBinaryUnifiedIdeographV1> + DataProvider<PropertyBinaryUppercaseV1> + DataProvider<PropertyBinaryVariationSelectorV1> + DataProvider<PropertyBinaryWhiteSpaceV1> + DataProvider<PropertyBinaryXidContinueV1> + DataProvider<PropertyBinaryXidStartV1>,
pub fn try_new_for_ecma262_unstable<P>(
provider: &P,
prop: &[u8],
) -> Option<Result<Self, DataError>>where
P: ?Sized + DataProvider<PropertyBinaryAsciiHexDigitV1> + DataProvider<PropertyBinaryAlphabeticV1> + DataProvider<PropertyBinaryBidiControlV1> + DataProvider<PropertyBinaryBidiMirroredV1> + DataProvider<PropertyBinaryCaseIgnorableV1> + DataProvider<PropertyBinaryCasedV1> + DataProvider<PropertyBinaryChangesWhenCasefoldedV1> + DataProvider<PropertyBinaryChangesWhenCasemappedV1> + DataProvider<PropertyBinaryChangesWhenLowercasedV1> + DataProvider<PropertyBinaryChangesWhenNfkcCasefoldedV1> + DataProvider<PropertyBinaryChangesWhenTitlecasedV1> + DataProvider<PropertyBinaryChangesWhenUppercasedV1> + DataProvider<PropertyBinaryDashV1> + DataProvider<PropertyBinaryDefaultIgnorableCodePointV1> + DataProvider<PropertyBinaryDeprecatedV1> + DataProvider<PropertyBinaryDiacriticV1> + DataProvider<PropertyBinaryEmojiV1> + DataProvider<PropertyBinaryEmojiComponentV1> + DataProvider<PropertyBinaryEmojiModifierV1> + DataProvider<PropertyBinaryEmojiModifierBaseV1> + DataProvider<PropertyBinaryEmojiPresentationV1> + DataProvider<PropertyBinaryExtendedPictographicV1> + DataProvider<PropertyBinaryExtenderV1> + DataProvider<PropertyBinaryGraphemeBaseV1> + DataProvider<PropertyBinaryGraphemeExtendV1> + DataProvider<PropertyBinaryHexDigitV1> + DataProvider<PropertyBinaryIdsBinaryOperatorV1> + DataProvider<PropertyBinaryIdsTrinaryOperatorV1> + DataProvider<PropertyBinaryIdContinueV1> + DataProvider<PropertyBinaryIdStartV1> + DataProvider<PropertyBinaryIdeographicV1> + DataProvider<PropertyBinaryJoinControlV1> + DataProvider<PropertyBinaryLogicalOrderExceptionV1> + DataProvider<PropertyBinaryLowercaseV1> + DataProvider<PropertyBinaryMathV1> + DataProvider<PropertyBinaryNoncharacterCodePointV1> + DataProvider<PropertyBinaryPatternSyntaxV1> + DataProvider<PropertyBinaryPatternWhiteSpaceV1> + DataProvider<PropertyBinaryQuotationMarkV1> + DataProvider<PropertyBinaryRadicalV1> + DataProvider<PropertyBinaryRegionalIndicatorV1> + DataProvider<PropertyBinarySentenceTerminalV1> + DataProvider<PropertyBinarySoftDottedV1> + DataProvider<PropertyBinaryTerminalPunctuationV1> + DataProvider<PropertyBinaryUnifiedIdeographV1> + DataProvider<PropertyBinaryUppercaseV1> + DataProvider<PropertyBinaryVariationSelectorV1> + DataProvider<PropertyBinaryWhiteSpaceV1> + DataProvider<PropertyBinaryXidContinueV1> + DataProvider<PropertyBinaryXidStartV1>,
A version of Self::new_for_ecma262 that uses custom data provided by a DataProvider.